Skip to content

fix(v8): passing the InnerTrap::User through the v8 backend#6541

Merged
marxin merged 3 commits intomainfrom
v8-error-propagation
May 6, 2026
Merged

fix(v8): passing the InnerTrap::User through the v8 backend#6541
marxin merged 3 commits intomainfrom
v8-error-propagation

Conversation

@marxin
Copy link
Copy Markdown
Contributor

@marxin marxin commented May 4, 2026

Fixes: #6540

Copilot AI review requested due to automatic review settings May 4, 2026 08:27
@marxin marxin requested a review from syrusakbary as a code owner May 4, 2026 08:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 --v8 treats proc_exit(0) as success.
  • Adjust V8 trap serialization/deserialization to round-trip InnerTrap::User through the wasm-c-api trap message.
  • Advertise V8 exception-handling support in the engine feature set and add v8 to 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 then unwrap()s the hex parse and does ptr::read on 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 to InnerTrap::CApi instead 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>)

Comment thread lib/api/src/backend/v8/error.rs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@syrusakbary syrusakbary left a comment

Choose a reason for hiding this comment

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

Nice!

@marxin marxin enabled auto-merge (squash) May 6, 2026 08:53
@marxin marxin merged commit c459d0a into main May 6, 2026
72 checks passed
@marxin marxin deleted the v8-error-propagation branch May 6, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v8: WasiError(ExitCode::0) leading to a misleading error

3 participants