From 354e5cc7830457d8249e320e2885be9c19804645 Mon Sep 17 00:00:00 2001 From: Jan Bujak Date: Wed, 23 Nov 2022 05:32:05 +0000 Subject: [PATCH] Enabled improved panic error reporting by default --- client/executor/runtime-test/Cargo.toml | 2 +- primitives/io/Cargo.toml | 19 ------------------- primitives/io/src/lib.rs | 20 ++------------------ 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index c8b173de16e9f..891ebe9ec460e 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] paste = "1.0.6" sp-core = { version = "7.0.0", default-features = false, path = "../../../primitives/core" } -sp-io = { version = "7.0.0", default-features = false, features = ["improved_panic_error_reporting"], path = "../../../primitives/io" } +sp-io = { version = "7.0.0", default-features = false, path = "../../../primitives/io" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../../primitives/runtime" } sp-sandbox = { version = "0.10.0-dev", default-features = false, path = "../../../primitives/sandbox" } sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" } diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index 35f0fd9692eaa..130c7d6e8591a 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -70,22 +70,3 @@ with-tracing = [ disable_panic_handler = [] disable_oom = [] disable_allocator = [] - -# This feature flag controls the runtime's behavior when encountering -# a panic or when it runs out of memory, improving the diagnostics. -# -# When enabled the runtime will marshal the relevant error message -# to the host through the `PanicHandler::abort_on_panic` runtime interface. -# This gives the caller direct programmatic access to the error message. -# -# When disabled the error message will only be printed out in the -# logs, with the caller receving a generic "wasm `unreachable` instruction executed" -# error message. -# -# This has no effect if both `disable_panic_handler` and `disable_oom` -# are enabled. -# -# WARNING: Enabling this feature flag requires the `PanicHandler::abort_on_panic` -# host function to be supported by the host. Do *not* enable it for your -# runtime without first upgrading your host client! -improved_panic_error_reporting = [] diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index 33516bb0397f3..a4889fa2bbcc1 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -1687,30 +1687,14 @@ mod allocator_impl { #[no_mangle] pub fn panic(info: &core::panic::PanicInfo) -> ! { let message = sp_std::alloc::format!("{}", info); - #[cfg(feature = "improved_panic_error_reporting")] - { - panic_handler::abort_on_panic(&message); - } - #[cfg(not(feature = "improved_panic_error_reporting"))] - { - logging::log(LogLevel::Error, "runtime", message.as_bytes()); - core::arch::wasm32::unreachable(); - } + panic_handler::abort_on_panic(&message); } /// A default OOM handler for WASM environment. #[cfg(all(not(feature = "disable_oom"), not(feature = "std")))] #[alloc_error_handler] pub fn oom(_: core::alloc::Layout) -> ! { - #[cfg(feature = "improved_panic_error_reporting")] - { - panic_handler::abort_on_panic("Runtime memory exhausted."); - } - #[cfg(not(feature = "improved_panic_error_reporting"))] - { - logging::log(LogLevel::Error, "runtime", b"Runtime memory exhausted. Aborting"); - core::arch::wasm32::unreachable(); - } + panic_handler::abort_on_panic("Runtime memory exhausted."); } /// Type alias for Externalities implementation used in tests.