Repository navigation
wasi: accept wasm i32 pointers with high bit set - #66636
Open
guybedford wants to merge 1 commit into
Open
guybedford wants to merge 1 commit into
guybedford wants to merge 1 commit into
Conversation
Wasm i32 arguments with the high bit set are passed to JS as negative Int32 numbers, so WASI functions taking uint32_t pointers rejected them with EINVAL. Accept Int32 in CheckType<uint32_t> and reinterpret as uint32_t on conversion, fixing all WASI functions at once. Fixes: nodejs#62671 Refs: nodejs#62822 Assisted-by: OpenCode Signed-off-by: Guy Bedford <guybedford@gmail.com>
Collaborator
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66636 +/- ##
==========================================
- Coverage 92.78% 90.42% -2.36%
==========================================
Files 422 791 +369
Lines 193692 276596 +82904
Branches 29881 53117 +23236
==========================================
+ Hits 179718 250120 +70402
- Misses 13645 16869 +3224
- Partials 329 9607 +9278
🚀 New features to boost your workflow:
|
jasnell
approved these changes
Oct 10, 2026
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: #62671
Refs: #62822
Wasm i32 arguments with the high bit set are passed to JS as negative Int32 numbers, so all WASI functions taking
uint32_tpointers rejected them withEINVAL. This was hit by Rspack with WASI modules using >2GB of linear memory.This takes the general approach suggested in #62822:
CheckType<uint32_t>now accepts eitherUint32orInt32, andConvertType<uint32_t>reinterprets a negativeInt32asuint32_t, so every WASI function is fixed rather than justclock_time_get. The fast API path already received rawuint32_tand was unaffected.The test calls
clock_time_getandargs_sizes_getwith pointer0x80000000against a 1-page memory and assertsEOVERFLOWrather thanEINVAL, so no large memory allocation is needed.