Skip to content
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

"Disposing the isolate that is entered by a thread" for some exotic objects #320

Closed
bnoordhuis opened this issue Sep 21, 2024 · 0 comments · Fixed by #321
Closed

"Disposing the isolate that is entered by a thread" for some exotic objects #320

bnoordhuis opened this issue Sep 21, 2024 · 0 comments · Fixed by #321
Labels
bug/crash Bugs specific to crashes, segfaults, etc. Gem can be installed though.

Comments

@bnoordhuis
Copy link
Collaborator

require "mini_racer"
puts MiniRacer::Context.new.eval("
var b = [0,97,115,109,1,0,0,0,1,26,5,80,0,95,0,80,0,95,1,127,0,96,0,1,110,96,1,100,2,1,111,96,0,1,100,3,3,4,3,3,2,4,7,26,2,12,99,114,101,97,116,101,83,116,114,117,99,116,0,1,7,114,101,102,70,117,110,99,0,2,9,5,1,3,0,1,0,10,23,3,8,0,32,0,20,2,251,27,11,7,0,65,12,251,0,1,11,4,0,210,0,11,0,44,4,110,97,109,101,1,37,3,0,11,101,120,112,111,114,116,101,100,65,110,121,1,12,99,114,101,97,116,101,83,116,114,117,99,116,2,7,114,101,102,70,117,110,99]
var o = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array(b))).exports
o.refFunc()(o.createStruct)
")
$ bundle exec ruby t.rb 
/usr/lib/ruby/3.0.0/json/common.rb:216:in `parse': 809: unexpected token at 'undefined' (JSON::ParserError)
        from /usr/lib/ruby/3.0.0/json/common.rb:216:in `parse'
        from /home/bnoordhuis/src/mini_racer/lib/mini_racer.rb:237:in `eval_unsafe'
        from /home/bnoordhuis/src/mini_racer/lib/mini_racer.rb:237:in `block (2 levels) in eval'
        from /home/bnoordhuis/src/mini_racer/lib/mini_racer.rb:358:in `timeout'
        from /home/bnoordhuis/src/mini_racer/lib/mini_racer.rb:236:in `block in eval'
        from /home/bnoordhuis/src/mini_racer/lib/mini_racer.rb:234:in `synchronize'
        from /home/bnoordhuis/src/mini_racer/lib/mini_racer.rb:234:in `eval'
        from t.rb:2:in `<main>'

#
# Fatal error in v8::Isolate::Dispose()
# Disposing the isolate that is entered by a thread
#

Trace/breakpoint trap (core dumped)

V8's JSON.stringify returns undefined, which Ruby's JSON parser rejects by calling rb_raise() and longjmping out of a lexical scope where we hold the v8::Locker

@bnoordhuis bnoordhuis added the bug/crash Bugs specific to crashes, segfaults, etc. Gem can be installed though. label Sep 21, 2024
bnoordhuis added a commit to bnoordhuis/mini_racer that referenced this issue Sep 21, 2024
mini_racer uses V8's JSON.stringify to serialize results but it
returns undefined instead of a string for certain inputs, like WASM
string refs.

When that undefined value is then passed to Ruby's JSON parser, it
raises an exception (using rb_raise) that longjmps out of a lexical
scope where we hold the v8::Locker, without properly unlocking it
again.

Fixes: rubyjs#320
bnoordhuis added a commit to bnoordhuis/mini_racer that referenced this issue Sep 21, 2024
mini_racer uses V8's JSON.stringify to serialize results but it
returns undefined instead of a string for certain inputs, like WASM
string refs.

When that undefined value is then passed to Ruby's JSON parser, it
raises an exception (using rb_raise) that longjmps out of a lexical
scope where we hold the v8::Locker, without properly unlocking it
again.

Fixes: rubyjs#320
bnoordhuis added a commit that referenced this issue Sep 21, 2024
mini_racer uses V8's JSON.stringify to serialize results but it
returns undefined instead of a string for certain inputs, like WASM
string refs.

When that undefined value is then passed to Ruby's JSON parser, it
raises an exception (using rb_raise) that longjmps out of a lexical
scope where we hold the v8::Locker, without properly unlocking it
again.

Fixes: #320
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/crash Bugs specific to crashes, segfaults, etc. Gem can be installed though.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant