From owner-freebsd-stable Thu Jul 12 11:46: 2 2001 Delivered-To: freebsd-stable@freebsd.org Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by hub.freebsd.org (Postfix) with ESMTP id 170D237B401; Thu, 12 Jul 2001 11:45:55 -0700 (PDT) (envelope-from arno@heho.snv.jussieu.fr) Received: from heho.snv.jussieu.fr (heho.snv.jussieu.fr [134.157.37.22]) by shiva.jussieu.fr (8.11.3/jtpda-5.3.3) with ESMTP id f6CIjqD26092 ; Thu, 12 Jul 2001 20:45:53 +0200 (CEST) Received: from (arno@localhost) by heho.snv.jussieu.fr (8.11.4/jtpda-5.2) id f6CIjqX06355 ; Thu, 12 Jul 2001 20:45:52 +0200 (MEST) From: arno@heho.snv.jussieu.fr (Arno J. Klaassen) To: jasone@FreeBSD.ORG Cc: freebsd-stable@FreeBSD.ORG Subject: Changed behaviour of pthread_join (bug?) Date: 12 Jul 2001 20:45:52 +0200 Message-ID: Lines: 161 X-Mailer: Gnus v5.7/Emacs 20.7 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Dear Sir, since the recent (Jun 23 -- Jul 6) MFCs in lib/libc_r/uthread, our pthread programs don't function any longer. The problem is that a joining a thread which has been cancelled, either fails (with errno <3>) or hangs in _thread_sys_poll : gdb -core join_bug-bsd.core GNU gdb 4.18 Core was generated by `join_bug-bsd'. Program terminated with signal 3, Quit. Reading symbols from /usr/lib/libc_r.so.4...done. Reading symbols from /usr/libexec/ld-elf.so.1...done. #0 0x280bb000 in _thread_sys_poll () from /usr/lib/libc_r.so.4 (gdb) where #0 0x280bb000 in _thread_sys_poll () from /usr/lib/libc_r.so.4 #1 0x280ba365 in _thread_kern_sched_state_unlock () from /usr/lib/libc_r.so.4 #2 0x280b9c64 in _thread_kern_scheduler () from /usr/lib/libc_r.so.4 #3 0x0 in ?? () (gdb) At the end of this mail you find a simple code fragment which produces this behaviour. This code runs perfectly well under Solaris2.5 as well as well as on a 4.3-STABLE #0: Sun Jun 10 00:24:49 MEST 2001 box. Thanx in advance. Arno J. Klaassen -- SCITO S.A. INSERM U483 Le Grand Sablon University Pierre et Marie Curie 4, avenue de l'Obiou 9, quai Saint Bernard 38700 La Tronche 75 252 Paris Cedex 5 +33 - 1 - 44 27 33 87 arno@ccr.jussieu.fr ################################################################### #include #include #include #include #include #include #include pthread_t control_thread; pthread_t scheduler_thread; #define NR_OF_ITERATIONS 500000 #define NR_OF_TESTMIPS_THREADS 10 static void * testmips (void *data) { int i; int a = 2; int b = 3; for (i = 1; i <= NR_OF_ITERATIONS; i++) { a += (b / a); a -= (b / a); } return NULL; } static void * scheduler (void * data) { int i = 0; int ret = 0; pthread_t testmips_thread; for (i = 1; i <= NR_OF_TESTMIPS_THREADS; i++) { pthread_testcancel(); fprintf (stderr, "Starting new testmips_thread <%d>.\n", i); pthread_create (&testmips_thread, 0, testmips, NULL); ret = pthread_join (testmips_thread, NULL); if (ret != 0) fprintf(stderr, " FAILED to join testmips_thread.\n"); else fprintf(stderr, " Successfully joined testmips_thread.\n"); } fprintf (stderr, "Routine 'scheduler' finished.\n"); fprintf(stderr, "\nPRESS ENTER TO STOP.\n\n"); scheduler_thread = NULL; return NULL; } static void * control_routine (void * data) { int ret; fprintf(stderr, "PRESS ENTER TO CANCEL THE TESTMIPS SCHEDULER.\n\n"); getchar(); if (scheduler_thread != NULL) { fprintf(stderr, "\n Canceling scheduler_thread.\n"); ret = pthread_cancel (scheduler_thread); if (ret != 0) { fprintf(stderr, " FAILED to cancel scheduler_thread.\n"); fprintf(stderr, " Errno nr is <%d>.\n", errno); } fprintf(stderr, " Trying to join scheduler_thread.\n"); ret = pthread_join (scheduler_thread, NULL); if (ret != 0) { fprintf(stderr, " FAILED to join scheduler_thread with errno <%d>.\n", errno); } else fprintf(stderr, " Successfully joined scheduler_thread.\n"); } fprintf (stderr, "Routine 'control_routine' finished.\n"); /* control_thread = NULL;*/ return NULL; } static void do_the_job(void) { pthread_create (&scheduler_thread, 0, scheduler, NULL); } int main (int argc, char *argv[]) { int ret; pthread_create (&control_thread, 0, control_routine, NULL); do_the_job(); ret = pthread_join (control_thread, NULL); if (ret != 0) fprintf(stderr, " FAILED to join control_thread.\n"); return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message