From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33909 invoked by alias); 20 May 2015 00:06:30 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 33803 invoked by uid 48); 20 May 2015 00:06:26 -0000 From: "msebor at redhat dot com" To: glibc-bugs@sourceware.org Subject: [Bug nptl/18435] New: pthread_once hangs when init routine throws an exception Date: Wed, 20 May 2015 00:06:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: nptl X-Bugzilla-Version: 2.21 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg00178.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=18435 Bug ID: 18435 Summary: pthread_once hangs when init routine throws an exception Product: glibc Version: 2.21 Status: NEW Severity: normal Priority: P2 Component: nptl Assignee: unassigned at sourceware dot org Reporter: msebor at redhat dot com CC: drepper.fsp at gmail dot com Target Milestone: --- As discussed in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=66146, pthread_once on at least ARM and PowerPC (but not x86_64) doesn't interact well with C++ exceptions thrown from the init routine. The following test case demonstrates the problem: it hangs in pthread_once until it's interrupted by SIGALRM. The test case runs successfully to completion on x86_64. $ cat /home/remote/msebor/tmp/once.cc && g++ -Wall -g -lpthread /home/remote/msebor/tmp/once.cc && gdb -batch -q -ex "catch signal SIGALRM" -ex r -ex bt ./a.out #include #include #include #include #include static pthread_once_t once = PTHREAD_ONCE_INIT; struct OnceException { }; static int niter; static void init_routine (void) { if (niter < 2) throw OnceException (); } int main (void) { int result = 1; alarm (5); for (niter = 0; niter != 3; ++niter) { try { int rc = pthread_once (&once, init_routine); if (rc) fprintf (stderr, "pthread_once failed: %i (%s)\n", rc, strerror (rc)); if (niter < 2) fputs ("pthread_once unexpectedly returned without" " throwing an exception", stderr); } catch (OnceException) { if (1 < niter) fputs ("pthread_once unexpectedly threw", stderr); result = 0; } catch (...) { fputs ("pthread_once threw an unknown exception", stderr); } if (result) break; } return result; } Catchpoint 1 (signal SIGALRM) [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/power8/libthread_db.so.1". Catchpoint 1 (signal SIGALRM), 0x00003fffb7f4f7bc in pthread_once () from /lib64/power8/libpthread.so.0 #0 0x00003fffb7f4f7bc in pthread_once () from /lib64/power8/libpthread.so.0 #1 0x0000000010000c0c in main () at /home/remote/msebor/tmp/once.cc:25 -- You are receiving this mail because: You are on the CC list for the bug.