-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution error with array.new_fixed and node v21.3.0 and V8 version 11.7.439.16 #6176
Comments
The wat doesn't look valid, $ bin/wasm-opt a.wat -all
[wasm-validator error in function stuff] local.set's value type must be correct, on
(local.set $0
(array.new_fixed $2 2
(i32.const 3)
(i32.const 5)
)
)
Fatal: error validating input That error looks correct. The (module
(type $0 (array i32))
(type $2 (array (mut i32))) (there is no subtyping between them, and there also cannot be subtyping between them because of the difference in mutability). How was the wat generated? |
Thanks for the quick response. The wat was generated using binaryen emitText. |
Does that wasm pass validation before emitting the text? (If it does, then it's definitely a bug.) |
Fixed the 'mut' issue, now I have:
Now I get: |
I now run module.validate() before emitText() and it doesn't shout |
That wat in binary form loads ok in latest V8 for me. Perhaps node has a newer version with latest V8? If not you may need to try with either the (latest) V8 shell ( I am guessing your node has an old-enough V8 that it has an older version of the binary format for WasmGC, which was updated just two months ago or so. |
Thanks for your help. Just upgraded to latest i.e. v21.4.0 and it doesn't fix the issue. |
Using latest d8 (V8 version 11.7.439.16), I'm able to reproduce the issue. I run d8 as follows:
In d8, I run the following:
This triggers the following error: CompileError: WebAssembly.Module(): section was shorter than expected size (9 bytes expected, 8 decoded) @+18 What am I doing wrong ? n.b. this is using my typescript branch, forked from commit 66277f9 |
FWIW I tried converting the wat to wasm using wat2wasm but the latest release 1.0.34 does not yet support GC: |
Similarly, using binaryen.js 116.0.0, which relies on binaryen commit https://github.com/WebAssembly/binaryen/tree/11dba9b1c2ad988500b329727f39f4d8786918c5, the generated wasm is identical to the one attached above:
|
Here is my (manual!) disassembly of the generated wasm. Given the error: 00 61 73 6D magic 01 types section 03 functions section 07 exports section 0A code section |
News from the battlefront:
|
Also doesn't work (loads but doesn't return usable data) in latest Chromium... So to sum up, as of writing:
I'm beginning to think that:
qq: would you know where I can download v8 12.2 for Mac (I'd rather avoid building it locally) |
I don't think there is a mapping of wasm Array types to JS TypedArrays. There has been discussion about it, but no concrete spec yet. Typically what people do for now is call into the wasm to do each To download recent VM builds, try jsvu. |
Thanks for the link to jsvu! |
I'm not sure if there are active discussions, but this is the last update I am aware of, which links to relevant places, @tlively might know more. |
Correct, all GC objects including arrays are completely opaque to JS and have to be accessed via exported Wasm functions. There is broad interest in improving this somehow, but all the obvious design would be technically challenging for engines to implement, so I wouldn't expect the situation to change any time soon. |
Thank you both ! |
@kripken FYI there are no pre-built V8 binaries for maces, so jsvu. It's gonna be the hard way... |
FYI I have migrated to Deno, which has a much fresher version of v8 |
Hi,
Using binaryen with GC instructions.
I have the following pseudo-code:
export function stuff(): i32[] { const a:i32[] = [ 3, 5 ]; return a; }
From it, I'm able to generate the following wat (using module.emitText():
and the corresponding wasm.
Interestingly, when I run the wasm with just the --experimental-wasm-gc node shouts as follows:
CompileError: WebAssembly.Module(): invalid value type 'stringview_wtf8ref', enable with --experimental-wasm-stringref @+17
This seems a bit weird since the above wat does not use sotringview at all...
If I enable
--experimental-wasm-stringref
the above error goes away, but then I get:CompileError: WebAssembly.Module(): unknown type form: 0 @+18
Digging around, I see that WASM GS support in v8 is pretty mature. Could this be caused by a bug in Binaryen itself ?
Or is there something wrong in the above wat ?
The text was updated successfully, but these errors were encountered: