• SorteKanin ( SorteKanin@feddit.dk ) OP
    link
    fedilink
    arrow-up
    2
    ·
    10 hours ago

    Panics in Rust default to stack unwinding, which I believe is similar to how exceptions work in C++. I don’t believe an unhandled exception in C++ kills other threads either? Could be wrong.

    Panics can also be configured to instead abort the process immediately, which is the exit(status) way. Obviously with that solution you can never observe a poisoned mutex so you would never need a poisoning mutex in that situation anyway.

    • 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