This repository was archived by the owner on Mar 24, 2022. It is now read-only.
💢 Package unknown hostcall panics into termination details#572
Merged
💢 Package unknown hostcall panics into termination details#572
Conversation
This prevents panics that aren't intentionally initiated by the Lucet runtime from attempting to unwind across Wasm stack frames. When #254 lands, this will no longer be necessary, but until then this allows us to safely transport the unknown panic payload across the FFI boundary so that panicking can resume on the other side.
iximeow
approved these changes
Jul 29, 2020
Contributor
iximeow
left a comment
There was a problem hiding this comment.
🎉 panics, but less crashy! Approving on the assumption I've properly understood the boxed-box piece.
| TerminationDetails::OtherPanic(p) => lucet_terminated { | ||
| reason: lucet_terminated_reason::OtherPanic, | ||
| // double box the panic payload so that the pointer passed to FFI | ||
| // land is thin |
Contributor
There was a problem hiding this comment.
took a moment to remember that non-thin-pointer types don't have FFI-stable layouts. That's what's going on here, right?
Contributor
Author
There was a problem hiding this comment.
Exactly; Box::into_raw(x) where x is Box<dyn T> returns a *mut dyn T, which is two machine pointers wide for the vtable, so casting it to *mut c_void to store in the struct would be Bad. The extra box makes the returned raw pointer have the type *mut Box<dyn T>, which is fine because the vtable pointer is then stored in the box on the heap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This prevents panics that aren't intentionally initiated by the Lucet runtime from attempting to unwind across Wasm stack frames. When #254 lands, this will no longer be necessary, but until then this allows us to safely transport the unknown panic payload across the FFI boundary so that panicking can resume on the other side.