From 2e82fdbe1625b63b5ffe895138b8c3652cc2579c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 9 Nov 2018 12:18:58 -0800 Subject: [PATCH] Don't worry about descriptive strings for malloc errors This commit updates the `__wbindgen_malloc` shim to avoid throwing a descriptive error in release mode. This is primarily done for two reasons: * If the function is gc'd out in release mode the `"invalid malloc request"` string is part of data and can't be gc'd automatically. * In some esoteric JS environments `TextDecoder` isn't always available, and this relatively core function is very quick to bring in that requirement early on. For example some recent experimentation with WebAudio worklets shows that they currently don't have the `TextDecoder` type available! --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 1ca443c99..cbb71f2e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -840,7 +840,11 @@ pub mod __rt { } } - super::throw_str("invalid malloc request"); + if cfg!(debug_assertions) { + super::throw_str("invalid malloc request") + } else { + std::process::abort(); + } } #[no_mangle]