-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement panic handler #1299
Implement panic handler #1299
Conversation
044a5f6
to
21f8449
Compare
Looks good! Looking forward to the wasmvm / wasmd changes. |
Wow, this is amazing. I tried it and got:
So much nicer than "unreachable". Either I didn't think of this approach, or it didn't work when I tried, but this would have saved lots of headaches the last year. You deserve a few of these 🏅 🏅 🏅 🏅 🏅 🏅 🏅 🏅 🏅 🏅 🏅 |
I only took a brief look at the code to understand the flow and it makes sense. I didn't do a detailed view of lifetimes or such. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some thinking, I realized the feature flag is unnecessary, the import alone will enforce this properly.
Otherwise, still happy with the architecture
packages/std/src/exports.rs
Outdated
use crate::query::CustomQuery; | ||
use crate::results::{ContractResult, QueryResponse, Reply, Response}; | ||
use crate::serde::{from_slice, to_vec}; | ||
use crate::types::Env; | ||
use crate::{CustomMsg, Deps, DepsMut, MessageInfo}; | ||
|
||
#[cfg(feature = "abort")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this at all.
This is a request from the Go/Wasmd runtime that it provides a feature, something which is passed through between the Wasm contract and the Go runtime.
This is not the case here
34b2b48
to
2ba4f84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. 🚀
/// | ||
/// This overrides any previous panic handler. See <https://doc.rust-lang.org/std/panic/fn.set_hook.html> | ||
/// for details. | ||
#[cfg(feature = "abort")] | ||
#[cfg(all(feature = "abort", target_arch = "wasm32"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point. This would not work outside of wasm32 anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah and we get unused warnings otherwise because there is no other usage then exports.rs
. First I wanted to keep the function available in docs, but since it is private it does not matter.
@@ -484,7 +484,7 @@ fn execute_panic() { | |||
); | |||
match execute_res.unwrap_err() { | |||
VmError::RuntimeErr { msg, .. } => { | |||
assert_eq!(msg, "Wasmer runtime error: RuntimeError: unreachable") | |||
assert_eq!(msg, "Wasmer runtime error: RuntimeError: Aborted: panicked at 'This page intentionally faulted', src/contract.rs:195:5") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Great, thanks for the input. Happy to avoid the unnecessary feature. |
Closes #1296
This shows how we can get the full panic information out of Wasm.