public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/28145]  New: libstdc++ and pthread cancellation are incompatible (at least with NPTL)
@ 2006-06-23 18:15 drow at gcc dot gnu dot org
  2006-06-23 18:26 ` [Bug libstdc++/28145] " mark at codesourcery dot com
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: drow at gcc dot gnu dot org @ 2006-06-23 18:15 UTC (permalink / raw)
  To: gcc-bugs

(This is not a new problem, and everyone involved is familiar with it.  I was
just surprised not to find a record of it in bugzilla.)

On targets using a recent version of glibc and the NPTL threading package, if
you cancel a thread using pthread_cancel while it is writing to an ostream,
you'll get a fatal error and an abort from glibc.  The abort happens because
std::ostream::put uses catch(...), catches the cancellation exception, and does
not rethrow it.  You can write a nasty workaround for this, but I'm obviously
not going to recommend it:

int cancelled = 0;                                                              
try {                                                                           
 pthread_cleanup_push(something-to-set-cancelled);                              
  write()                                                                       
  pthread_cleanup_pop(discard-cleanups);                                        
} catch (...) {                                                                 
  if (cancelled) throw;                                                         
  normal-catch-handling;
}                                                                               

That would only work if there was nothing marked throw() on the way up, of
course.

This problem has been discussed at length on the c++-pthreads list, but I don't
think a consensus was really reached.


-- 
           Summary: libstdc++ and pthread cancellation are incompatible (at
                    least with NPTL)
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drow at gcc dot gnu dot org
GCC target triplet: *-*-linux*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28145


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-07-16 19:21 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-23 18:15 [Bug libstdc++/28145] New: libstdc++ and pthread cancellation are incompatible (at least with NPTL) drow at gcc dot gnu dot org
2006-06-23 18:26 ` [Bug libstdc++/28145] " mark at codesourcery dot com
2006-06-24  1:48 ` [Bug libstdc++/28145] C++ (throw() and catch(...) {/* fall through */ } ) " pinskia at gcc dot gnu dot org
2006-06-24  3:45 ` [Bug other/28145] " drow at gcc dot gnu dot org
2006-06-24  4:19 ` mark at codesourcery dot com
2006-07-07 17:18 ` pcarlini at suse dot de
2006-07-31  9:38 ` jason at gcc dot gnu dot org
2006-07-31  9:40 ` jason at gcc dot gnu dot org
2006-08-01  2:13 ` jason at gcc dot gnu dot org
2006-08-01  2:33 ` jason at gcc dot gnu dot org
2006-08-01  2:48 ` drow at gcc dot gnu dot org
2006-08-01  7:11 ` jason at redhat dot com
2006-08-01 13:02 ` drow at gcc dot gnu dot org
2006-08-01 21:08 ` jason at gcc dot gnu dot org
2006-11-01 23:33 ` hhinnant at apple dot com
2007-04-13 19:13 ` jason at redhat dot com
2007-04-15 15:14 ` hhinnant at apple dot com
2007-04-15 18:01 ` jason at redhat dot com
2010-07-16 19:21 ` jason at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).