1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 15:32:43 +01:00

libutil: Try to call std::terminate for panic

We now have a terminate handler that prints a
stack trace, which is useful to have when encountering
an unreachable.
This commit is contained in:
Sergei Zimmerman 2025-08-29 00:02:11 +03:00
parent 731349639f
commit 1f607b5def
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -436,7 +436,7 @@ void panic(std::string_view msg)
writeErr("\n\n" ANSI_RED "terminating due to unexpected unrecoverable internal error: " ANSI_NORMAL); writeErr("\n\n" ANSI_RED "terminating due to unexpected unrecoverable internal error: " ANSI_NORMAL);
writeErr(msg); writeErr(msg);
writeErr("\n"); writeErr("\n");
abort(); std::terminate();
} }
void panic(const char * file, int line, const char * func) void panic(const char * file, int line, const char * func)

View file

@ -299,20 +299,20 @@ using NativeSysError =
void throwExceptionSelfCheck(); void throwExceptionSelfCheck();
/** /**
* Print a message and abort(). * Print a message and std::terminate().
*/ */
[[noreturn]] [[noreturn]]
void panic(std::string_view msg); void panic(std::string_view msg);
/** /**
* Print a basic error message with source position and abort(). * Print a basic error message with source position and std::terminate().
* Use the unreachable() macro to call this. * Use the unreachable() macro to call this.
*/ */
[[noreturn]] [[noreturn]]
void panic(const char * file, int line, const char * func); void panic(const char * file, int line, const char * func);
/** /**
* Print a basic error message with source position and abort(). * Print a basic error message with source position and std::terminate().
* *
* @note: This assumes that the logger is operational * @note: This assumes that the logger is operational
*/ */