-
Notifications
You must be signed in to change notification settings - Fork 996
Closed
Description
I encountered an error with DataView while developing WebAssembly app.
This is a message in DevTool's Console tab of Chrome browser.
wasm_exec.js:236 Uncaught RangeError: Start offset -2093352176 is outside the bounds of the buffer
at new DataView (<anonymous>)
at loadString (wasm_exec.js:236:27)
at syscall/js.stringVal (wasm_exec.js:313:17)
at main.syscall/js.ValueOf (wasm.wasm:0x12a21)
at main.(:8088/syscall/js.Value).Set (http://localhost:8088/wasm.wasm)
at main.(:8088/*main.hoge).incr$bound (http://localhost:8088/wasm.wasm)
at main.runtime.resume$1 (wasm.wasm:0xe268)
at main.runtime.resume$1$gowrapper (wasm.wasm:0x94af)
at main.tinygo_launch (wasm.wasm:0x4e8)
at main.runtime.scheduler (wasm.wasm:0x95b4)
Environment
- OS: macOS Sequoia 15.3.1
- go version go1.23.1 darwin/arm64
- Google Chrome 133.0.6943.142(Official Build) (arm64)
$ tinygo version
tinygo version 0.36.0-dev-056394e2 darwin/arm64 (using go version go1.23.1 and LLVM version 19.1.7)
To reproduce the error
Assuming using Chrome web browser.
- Clone my sample repository.
- Build and run HTTP server.
# Build
cp "$(tinygo env TINYGOROOT)/targets/wasm_exec.js" ./wasm_exec.js
GOOS=js GOARCH=wasm tinygo build -o wasm.wasm ./main.go
# Run HTTP Server
go run localserver/server.go- Open http://localhost:8088 on your browser.
- Open
DevToolsand switch toConsoletab. - Push
RunButton several times. - After pushing button 22 times or so, an error message like the above will appear.
Maybe the amount of memory exceeds upper limit of int32 (2_147_483_648 bytes), and value_ptr in the first arg of syscall/js.stringVal becomes negative (unexpected) value.
One solution is to convert the value to unsigned. It solved the problem in my environment.
Metadata
Metadata
Assignees
Labels
No labels