Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

rust: unwind execution panics in evmc-declare#316

Merged
axic merged 1 commit intomasterfrom
rust-panic
Jun 6, 2019
Merged

rust: unwind execution panics in evmc-declare#316
axic merged 1 commit intomasterfrom
rust-panic

Conversation

@axic
Copy link
Copy Markdown
Member

@axic axic commented Jun 5, 2019

Fixes #310.

@axic axic requested a review from jakelang June 5, 2019 22:38
};

let result = container.execute(code_ref, &execution_context);
let result = ::std::panic::catch_unwind(|| {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not recommended to use this function for a general try/catch mechanism. The Result type is more appropriate to use for functions that can fail on a regular basis. Additionally, this function is not guaranteed to catch all panics, see the "Notes" section below.

https://doc.rust-lang.org/std/panic/fn.catch_unwind.html

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason for this change is exactly listed in your link:

It is currently undefined behavior to unwind from Rust code into foreign code, so this function is particularly useful when Rust is called from another language (normally C). This can run arbitrary Rust code, capturing a panic and allowing a graceful handling of the error.

@axic axic merged commit 9b2de67 into master Jun 6, 2019
@axic axic deleted the rust-panic branch June 6, 2019 12:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust: unwind panics for the execute method

2 participants