36
you are viewing a single comment's thread
view the rest of the comments
[-] fruitcantfly@programming.dev 3 points 2 days ago* (last edited 1 day ago)

I don’t believe an unhandled exception in C++ kills other threads either? Could be wrong.

An unhandled exception in C++ causes the program to call std::terminate, which calls std::abort by default and brings down the entire program. I don't think there's a way to prevent an unhandled exception from doing that without causing nasal demons, but I could likewise be wrong. According to the standard, regarding the function function called by std::terminate:

A std::terminate_handler shall terminate execution of the program without returning to the caller, otherwise the behavior is undefined.

A quick check suggests that GCC's std::terminate calls std::abort if your terminate handler does not, but I don't know if that applies to other implementations.

EDIT: If anyone else is curious, here is the GCC implementation:

void
__cxxabiv1::__terminate (std::terminate_handler handler) throw ()
{
  __try
    {
      handler ();
      std::abort ();
    }
  __catch(...)
    { std::abort (); }
}

The LLVM version does the same thing.

this post was submitted on 18 Nov 2026
36 points (100.0% liked)

Rust

8379 readers
30 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 3 years ago
MODERATORS