fix(v8): passing the InnerTrap::User through the v8 backend#6541
Merged
fix(v8): passing the InnerTrap::User through the v8 backend#6541
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #6540 by improving how the V8 backend propagates “user” traps (e.g., WASI proc_exit) so that ExitCode::0 is treated as a successful run instead of being surfaced as a misleading runtime error.
Changes:
- Add a CLI integration test to assert
wasmer run --v8treatsproc_exit(0)as success. - Adjust V8 trap serialization/deserialization to round-trip
InnerTrap::Userthrough the wasm-c-api trap message. - Advertise V8 exception-handling support in the engine feature set and add
v8to VS Code rust-analyzer features.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/integration/cli/tests/run.rs | Adds an integration test ensuring proc_exit(0) is considered success under V8. |
| lib/api/src/backend/v8/error.rs | Updates user-trap encoding/decoding in trap messages for V8. |
| lib/api/src/backend/v8/entities/engine.rs | Enables exceptions in V8’s reported supported features. |
| .vscode/settings.json | Adds the v8 feature to rust-analyzer’s enabled feature list. |
Comments suppressed due to low confidence (1)
lib/api/src/backend/v8/error.rs:106
- Decoding user traps via
message.split_once("🐛")is too permissive and can misclassify unrelated trap messages that happen to contain the marker. Because the code thenunwrap()s the hex parse and doesptr::readon the resulting address, a malformed/attacker-controlled message can cause a panic or UB. Tighten the detection (e.g., require an expected prefix like"Exception: 🐛"/"Error: 🐛"and ensure the remainder is exactly a hex pointer token), and handle parse failures by falling back toInnerTrap::CApiinstead of panicking/reading an arbitrary pointer.
if let Some((_, ptr_str)) = message.split_once("🐛") {
let ptr: Box<dyn Error + Send + Sync + 'static> = unsafe {
let r = ptr_str.trim_start_matches("0x");
std::ptr::read(usize::from_str_radix(r, 16).unwrap()
as *const Box<dyn Error + Send + Sync + 'static>)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes: #6540