Subject: pthreads, ENOMEM and glib
To: None <>
From: Patrick Welche <>
List: current-users
Date: 11/16/2006 19:41:25
Running gmake check on glib cvs-head, I see 2 failed tests in gthread,
essentially due to pthread_create returning ENOMEM. The only place
I can see is src/lib/libpthread/pthread.c:

    /* Fetch misc. attributes from the attr structure. */ 
    name = NULL;
    if ((p = nattr.pta_private) != NULL)
        if (p->ptap_name[0] != '\0')
            if ((name = strdup(p->ptap_name)) == NULL)
                return ENOMEM;

BTW pthread_create(3) says:

     pthread_create() shall fail if:

     [EAGAIN]           The system lacks the necessary resources to create
                        another thread, or the system-imposed limit on the
                        total number of threads in a process
                        PTHREAD_THREADS_MAX would be exceeded.

     [EINVAL]           The value specified by attr is invalid.

Any thoughts on how a strdup could fail? Espcially as

struct pthread_attr_private {
    char ptap_name[PTHREAD_MAX_NAMELEN_NP];

#define       PTHREAD_MAX_NAMELEN_NP  32

32 bytes doesn't seem like a huge amount of memory - ah ptap_name might
not be '\0' terminated... how...