WASM out of bounds memory access bugs #49
Labels
No Label
bug
core
design
errors
feature
infrastructure
optimization
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: twc/rudus#49
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm about to cry.
I've finally got all the fundamentals working, and WASM decides to throw a possibly show-ending bug. I don't know what to do.
To reproduce:
actors
, latest commitpkg
directory in a web browser, openhttp://localhost:8080/index.html
(or similar)ludus.run
to execute ludus code.Behaviour:
ludus.run(":foo")
gives us the proper result.ludus.run("print!(:foo);sleep!(3000);print!(:bar)")
These look different in different browsers.
In Firefox, we get "RuntimeError: index out of bounds." At byte 1_751_972 in
rudus_bg.wasm
. (The wat equivalent file is 57 megabytes. I cannot debug this.) Chrome is by far the most stable (so I'm not quite able to reproduce it right now), but we get an unhandled error in Promise, "Out of Bounds Memory Access." In Safari, it's reliably (but not uniquely or uniformly the case) that we get "Unhandled Promise Rejection: RuntimeError: Out of bounds memory access (evaluating 'wasm.closure327_externref_shim(arg0, arg1, arg2)')." It's noteworthy that Safari will even crash running a single-line synchronous Ludus script.I have tried several things to address this.
The most consequential of these has been to increase the stack size of whatever I build, which has made Chrome a reasonably stable target, and Firefox mostly stable. To do this, I dropped
export CARGO_BUILD_RUSTFLAGS="-Clink-arg=-zstack-size=1000000"
into the command line. (Why are we using an environment variable for this?) I learned about this through a link now lost to time.From this link, I spent some time trying to figure out how to use
talc
instead of the default allocator; that didn't help (and was very slow?).Related links:
init
twice?A few maybe-maybe-not related issues:
ludus.run
twice in the same console session, because the run verb is getting passed through the worker to ludus, which doesn't know how to respond to a run verb. This is very strange to be, because the previous runs go to completion, and that means theworld
loop should have returned, but apparently it hasn't.run
function bound toonmessage
in the worker setsinitialized
totrue
... not right away but afterawait init()
.Fixing the ordering here actually FIXED THIS ISSUE. I think.
The Firefox-doesn't-kill-the-Ludus-VM properly is a different issue. One to fix.
@matt I think I just put this to bed, as you see. But if you could pull the most recent commit from the
actors
branch down and see what happens if/when you serve this on your machine, that would be swell.FWIW, this is the relevant commit:
4e7557cbcc
Okay! Done.