Register LLVM handlers for bad-alloc / OOM

LLVM's default bad-alloc handler may throw if exceptions are enabled,
and `operator new` isn't hooked at all by default. Now we register our
own handler that prints a message similar to fatal errors, then aborts.
We also call the function that registers the C++ `std::new_handler`.
This commit is contained in:
Josh Stone 2024-03-15 15:49:06 -07:00
parent 1ca424ca43
commit 0ade5a11f5
3 changed files with 26 additions and 3 deletions

View file

@ -1519,7 +1519,7 @@ extern "C" {
#[link(name = "llvm-wrapper", kind = "static")]
extern "C" {
pub fn LLVMRustInstallFatalErrorHandler();
pub fn LLVMRustInstallErrorHandlers();
pub fn LLVMRustDisableSystemDialogsOnCrash();
// Create and destroy contexts.