Skip to content

wasi: avoid hard crash if start() is never called#33184

Closed
cjihrig wants to merge 1 commit into
nodejs:masterfrom
cjihrig:wasi-start
Closed

wasi: avoid hard crash if start() is never called#33184
cjihrig wants to merge 1 commit into
nodejs:masterfrom
cjihrig:wasi-start

Conversation

@cjihrig

@cjihrig cjihrig commented May 1, 2020

Copy link
Copy Markdown
Contributor

Prior to this commit, calling the WebAssembly instance's _start()
export directly would hard crash the process because the memory
was never configured. This commit adds an additional check that
the memory is usable. With this commit, calling _start() directly
will still lead to WASI exiting with a non-zero exit code, but
Node does not crash.

Fixes: #33175

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Prior to this commit, calling the WebAssembly instance's _start()
export directly would hard crash the process because the memory
was never configured. This commit adds an additional check that
the memory is usable. With this commit, calling _start() directly
will still lead to WASI exiting with a non-zero exit code, but
Node does not crash.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. wasi Issues and PRs related to the WebAssembly System Interface. labels May 1, 2020
@nodejs-github-bot

nodejs-github-bot commented May 1, 2020

Copy link
Copy Markdown
Collaborator

@cjihrig cjihrig added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 1, 2020
@tniessen

tniessen commented May 4, 2020

Copy link
Copy Markdown
Member

I didn't see this PR (or the issue) before opening #33235. Please consider it as an alternative:

  • Personally, I think a non-recoverable error (at least not recoverable from WASM) is more appropriate in case a WASI module was not started properly. With this PR, it is up to the WASM module to handle the error code EINVAL, even though the WASM module likely isn't at fault.
  • This PR doesn't prevent calling syscalls that don't access memory.

@cjihrig

cjihrig commented May 4, 2020

Copy link
Copy Markdown
Contributor Author

I'm good with the approach in #33235. I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. wasi Issues and PRs related to the WebAssembly System Interface.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Segfault on combo of global ctors, ostream, wasi

9 participants