public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Iain Sandoe <iain@sandoe.co.uk>
To: libstdc++@gcc.gnu.org
Subject: 18_support/nested_exception/rethrow_if_nested-term.cc
Date: Sun, 20 Aug 2023 11:08:23 +0100	[thread overview]
Message-ID: <DE1A37C3-B6A9-41DA-8EFA-11E8B24890DF@sandoe.co.uk> (raw)

Hi

I’ve been trying to figure out why the test from $SUBJECT fails when I use the c++abi library (either with clang or g++ and a modified libstdc++ that uses c++abi for it’s runtime support).

At the moment, I am not sure where exactly the issue lies - but I suspect it might be in implementation divergence over the set_terminate call.

The issue seems to center around interpretation of the following statement in the upstream cxxabi:

"	• The fields unexpectedHandler and terminateHandler contain pointers to the unexpected and terminate handlers at the point where the exception is thrown. The ISO C++ Final Draft International Standard [lib.unexpected] (18.6.2.4) states that the handlers to be used are those active immediately after evaluating the throw argument. If destructors change the active handlers during unwinding, the new values are not used until unwinding is complete.”

- but I cannot find that statement in the current C++ draft, instead it seems to say:

"It is unspecified which terminate_handler function will be called if an exception is active during a call to set_terminate. Otherwise calls the current terminate_handler function.” (https://eel.is/c++draft/support.exception#terminate).

— 

If I set the terminate handler before the throw, then the c++abi implementation works the same as the supc++ one.

For both runtime support libraries, if I inspect the current exception from the terminate handler it shows we have a _nested<A> .

So, ISTM that the difference is not in the actual nested exception handling (including the conditional rethrow) but lies, instead in a different interpretation of when the changes from set_terminate() take effect.

— it needs someone with state on the history of this to comment …

a) does that seem like a reasonable analysis?
b) would it be acceptable to move the set_terminate () call?
  - I can also make changes conditional on the support runtime - but trying to minimise those.

thanks
Iain


             reply	other threads:[~2023-08-20 10:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-20 10:08 Iain Sandoe [this message]
2023-08-20 11:21 ` 18_support/nested_exception/rethrow_if_nested-term.cc Jonathan Wakely
2023-08-20 13:01   ` 18_support/nested_exception/rethrow_if_nested-term.cc Iain Sandoe
2023-08-20 13:33     ` 18_support/nested_exception/rethrow_if_nested-term.cc Jonathan Wakely

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=DE1A37C3-B6A9-41DA-8EFA-11E8B24890DF@sandoe.co.uk \
    --to=iain@sandoe.co.uk \
    --cc=libstdc++@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: link
Be 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).