public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/45479] Exceptions not delivered properly after thread cancellation Date: Fri, 10 Sep 2010 10:11:00 -0000 [thread overview] Message-ID: <20100910101118.27911.qmail@sourceware.org> (raw) In-Reply-To: <bug-45479-19472@http.gcc.gnu.org/bugzilla/> ------- Comment #17 from redi at gcc dot gnu dot org 2010-09-10 10:11 ------- (In reply to comment #15) > In particular, it does not appear that the thread is being reliably cancelled > at the pthread_testcancel call - sometimes f2 seems to run beyond the > pthread_testcancel, As I said above, that's consistent with f2(50) executing before pthread_cancel. > which causes the throw to execute, and results in an abort > (seems to want to act like an uncaught exception propagated out). If you > comment out the throw, f2 will sometimes continue to construct additional > objects past 50. I have also noticed that sometimes a bunch of the Y objects > get destructed, but then the program suddenly summarily exits. I think that's because f2(50) leaves cancellation enabled and writing to cout is a cancellation point, so the exit happens when some ~Y destructor coincides with thread2 calling pthread_cancel. > I also tried > setting the cancellation type to asynchronous, but that doesn't make any > difference - sometimes it works, sometimes it don't. Its very unpredictable. Yes, race conditions tend to have unpredictable results. If I change the condition in f2 to (i >= 50) and disable cancellation again after the call to pthread_testcancel then I get more predictable behaviour, because that ensures that the only cancellation points are the calls to pthread_testcancel in f2, which still occur in f2(51), f2(52) etc. i.e. cancellation still occurs at the intended place even if f2(50) happens before the call to pthread_cancel. That seems to validate my theory that the cancel happens after f2(50), and so takes effect at the first cancellation point after the cancellation request. I don't think there's a gcc or glibc bug here, just non-portable code with indeterminate behaviour. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45479
prev parent reply other threads:[~2010-09-10 10:11 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-09-01 13:11 [Bug c++/45479] New: " mikedalpee at enginsol dot com 2010-09-01 13:13 ` [Bug c++/45479] " mikedalpee at enginsol dot com 2010-09-01 13:14 ` mikedalpee at enginsol dot com 2010-09-01 13:16 ` mikedalpee at enginsol dot com 2010-09-01 13:27 ` mikedalpee at enginsol dot com 2010-09-01 13:32 ` mikedalpee at enginsol dot com 2010-09-01 13:41 ` rguenth at gcc dot gnu dot org 2010-09-01 13:43 ` paolo dot carlini at oracle dot com 2010-09-01 13:54 ` paolo dot carlini at oracle dot com 2010-09-02 0:44 ` pinskia at gcc dot gnu dot org 2010-09-02 1:14 ` mikedalpee at enginsol dot com 2010-09-02 1:20 ` pinskia at gcc dot gnu dot org 2010-09-02 13:44 ` mikedalpee at enginsol dot com 2010-09-02 13:44 ` mikedalpee at enginsol dot com 2010-09-02 13:46 ` mikedalpee at enginsol dot com 2010-09-03 0:06 ` mikedalpee at enginsol dot com 2010-09-03 0:25 ` mikedalpee at enginsol dot com 2010-09-10 9:55 ` redi at gcc dot gnu dot org 2010-09-10 10:11 ` redi at gcc dot gnu dot org [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20100910101118.27911.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).