Title
Termination in C++ is unclear
Status
new
Section
[support.start.term][exception.terminate]
Submitter
JF Bastien

Created on 2018-03-15.00:00:00 last changed 72 months ago

Messages

Date: 2018-04-02.00:00:00

[ 2018-04-02 Priority set to 3 after discussion on the reflector. ]

Date: 2018-04-15.00:00:00

[ 2018-04-02, Jens comments ]

Any potential wording should carefully take [basic.start] into account, and maybe should actually be integrated into the core wording, not the library wording.

Date: 2018-03-15.00:00:00

It's unclear how different termination facilities in C++ interact (and how they interact with the C termination facilities). Individually some of these functions try to handle corner cases, but hilarity ensues when combined with each other. As a simple example, can an atexit handler call exit? If not, can it call quick_exit, and can then at_quick_exit handler call exit? Is it possible to install an atexit handler from an at_quick_exit, without strongly happens before, while handling a separate atexit handler (and what happens then)?

The termination handlers and termination conditions I collected:

  • returning from main calls atexit handlers.

  • atexit / exit

  • at_quick_exit / quick_exit

  • set_terminate

  • violating noexcept and other things that call std::terminate (see [except.terminate])

  • violating exception specification

  • parallel algorithms leaving with uncaught exception

  • some std::signal such as SIGTERM, SIGSEGV, SIGINT, SIGILL, SIGABRT, and (maybe?) SIGFPE.

  • set_unexpected (now a zombie)

  • unexpected_handler (now a zombie)

What's unclear is:

  • Is termination handling a DAG?

  • Which thread(s) are termination handlers called on?

  • Is program termination Turing complete?

I've written a sample program which exercises some of this, see here.

History
Date User Action Args
2018-04-03 18:56:45adminsetmessages: + msg9798
2018-04-03 18:56:45adminsetmessages: + msg9797
2018-03-15 00:00:00admincreate