[PATCH] for ex9 test case failure
Steven Munroe
sjmunroe@vnet.ibm.com
Fri May 3 13:31:00 GMT 2002
There a bug in ex9 that on SMP systems can result in two threads calling exit().
The net is that ex9 will segfault in "exit()" attempting to dereference "__exit_funcs".
diff -rc2P glibc-2.2.5/ChangeLog glibc-2.2.5-pthreads/ChangeLog
*** glibc-2.2.5/ChangeLog Sun Jan 20 21:20:18 2002
--- glibc-2.2.5-pthreads/ChangeLog Fri Apr 26 14:58:58 2002
***************
*** 1,2 ****
--- 1,8 ----
+ 2002-04-26 Steven Munroe <sjmunroe@us.ibm.com>
+
+ * linuxthreads/Examples/ex9.c
+ ex9 thread function is not thread safe and can call exit() from
+ two or more threads.
+
2002-01-18 Andreas Schwab <schwab@suse.de>
diff -rc2P glibc-2.2.5/linuxthreads/Examples/ex9.c glibc-2.2.5-pthreads/linuxthreads/Examples/ex9.c
*** glibc-2.2.5/linuxthreads/Examples/ex9.c Tue Jun 20 23:32:01 2000
--- glibc-2.2.5-pthreads/linuxthreads/Examples/ex9.c Fri Apr 26 14:55:51 2002
***************
*** 33,37 ****
main (void)
{
! pthread_t th;
int i;
--- 33,38 ----
main (void)
{
! pthread_t th;
! pthread_t thread_list[NUM_THREADS];
int i;
***************
*** 41,50 ****
for (i = 0; i < NUM_THREADS; i++)
{
! if (pthread_create (&th, NULL, thread, NULL) != 0)
error (EXIT_FAILURE, 0, "cannot create thread");
}
(void) thread (NULL);
! /* notreached */
return 0;
}
--- 42,56 ----
for (i = 0; i < NUM_THREADS; i++)
{
! if (pthread_create (&thread_list[i], NULL, thread, NULL) != 0)
error (EXIT_FAILURE, 0, "cannot create thread");
}
(void) thread (NULL);
!
! for (i = 0; i < NUM_THREADS; i++)
! {
! pthread_join(thread_list[i], NULL);
! }
!
return 0;
}
***************
*** 88,92 ****
++linecount, (unsigned long) self);
funlockfile (stdout);
! exit (0);
}
--- 94,100 ----
++linecount, (unsigned long) self);
funlockfile (stdout);
! return;
!
! /* exit (0); */
}
More information about the Libc-alpha
mailing list