This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi! My reading of pthread_getattr_np is that following code will crash: pthread_attr_t attr; memset (&attr, 0xaa, sizeof (attr)); // Stress that attr is uninitialized if (pthread_getattr_np (pthread_self (), &attr) == 0) pthread_attr_destroy (&attr); if sched_getaffinity returns ENOSYS. One way to fix this is below, another would be e.g. to clear whole pthread_attr_t at the start of pthread_getattr_np. That could cure even crashes on invalid careless code like e.g. boehm-gc does: my_pthread = pthread_self(); pthread_getattr_np (my_pthread, &attr); pthread_attr_getstack (&attr, (void **) &stack_addr, &stack_size); pthread_attr_destroy (&attr); (which has to be fixed anyway). 2007-06-22 Jakub Jelinek <jakub@redhat.com> * pthread_getattr_np.c (pthread_getattr_np): Clear cpuset and cpusetsize if pthread_getaffinity_np failed with ENOSYS. --- libc/nptl/pthread_getattr_np.c.jj 2007-06-04 08:42:05.000000000 +0200 +++ libc/nptl/pthread_getattr_np.c 2007-06-22 11:41:48.000000000 +0200 @@ -164,8 +164,12 @@ pthread_getattr_np (thread_id, attr) { free (cpuset); if (ret == ENOSYS) - /* There is no such functionality. */ - ret = 0; + { + /* There is no such functionality. */ + ret = 0; + iattr->cpuset = NULL; + iattr->cpusetsize = 0; + } } } Jakub
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |