[PATCH] __pthread_initializer_manager locking issue
Jakub Jelinek
jakub@redhat.com
Mon Jul 17 05:21:00 GMT 2000
Hi!
Without this, I get a SEGFAULT when trying to debug some threaded programs.
Basically, what happens is that __pthread_unlock is called on an unlocked
lock (__status = 0, __lock = 0). Is __pthread_unlock allowed to segfault on
such a spinlock btw? But this lead me to read the code and I think we must
lock __pthread_manager_thread.p_lock before calling clone, otherwise it does
not make any sense why the special __pthread_manager_event etc., because
that routine on an unlocked p_lock will just call __pthread_manager
immediately.
2000-07-17 Jakub Jelinek <jakub@redhat.com>
* pthread.c (__pthread_initialize_manager): Lock
__pthread_manager_thread.p_lock before calling clone.
--- libc/linuxthreads/pthread.c.jj Wed Jul 12 16:05:35 2000
+++ libc/linuxthreads/pthread.c Mon Jul 17 14:06:45 2000
@@ -444,6 +444,7 @@ int __pthread_initialize_manager(void)
| __pthread_initial_thread.p_eventbuf.eventmask.event_bits[idx]))
!= 0)
{
+ __pthread_lock(__pthread_manager_thread.p_lock, NULL);
pid = __clone(__pthread_manager_event,
(void **) __pthread_manager_thread_tos,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
@@ -465,9 +466,10 @@ int __pthread_initialize_manager(void)
/* Now call the function which signals the event. */
__linuxthreads_create_event ();
- /* Now restart the thread. */
- __pthread_unlock(__pthread_manager_thread.p_lock);
}
+
+ /* Now restart the thread. */
+ __pthread_unlock(__pthread_manager_thread.p_lock);
}
}
Jakub
More information about the Libc-hacker
mailing list