From: "byroot (Jean Boussier)" Date: 2021-11-26T16:46:57+00:00 Subject: [ruby-core:106292] [Ruby master Bug#18250] Anonymous variables seem to break `Ractor.make_shareable` Issue #18250 has been updated by byroot (Jean Boussier). I tried to backport these 5 commits and it does solve the problem in normal builds. However with `cppflags=-DRUBY_DEBUG` I do get the following error: ``` estISeq#test_cdhash_after_roundtripWe are killing the stack canary set by opt_case_dispatch, at @/Users/byroot/src/github.com/Shopify/ruby/test/ruby/test_iseq.rb:1>@pc=25 watch out the C stack trace. == disasm: #@/Users/byroot/src/github.com/Shopify/ruby/test/ruby/test_iseq.rb:1 (1,0)-(4,3)> (catch: FALSE) 0000 opt_getinlinecache 9, ( 1)[Li] 0003 putobject true 0005 getconstant :Class 0007 opt_setinlinecache 0009 opt_getinlinecache 18, 0012 putobject true 0014 getconstant :String 0016 opt_setinlinecache 0018 opt_send_without_block 0020 putstring "foo" 0022 opt_send_without_block 0024 dup 0025 opt_case_dispatch , 35 0028 dup ( 2) 0029 putobject "foo" 0031 checkmatch 2 0033 branchif 38 0035 pop ( 1) 0036 putnil 0037 leave ( 3) 0038 pop ( 2) 0039 putobject 42 ( 3)[Li] 0041 leave /Users/byroot/src/github.com/Shopify/ruby/test/ruby/test_iseq.rb:1: [BUG] see above. ``` From this test: ```ruby def test_cdhash_after_roundtrip # CDHASH was not built properly when loading from binary and # was causing opt_case_dispatch to clobber its stack canary # for its "leaf" instruction attribute. iseq = compile(<<~EOF) case Class.new(String).new("foo") when "foo" 42 end EOF assert_equal(42, ISeq.load_from_binary(iseq.to_binary).eval) end ``` That test was added in 4323fa96c4350ecad5f3d607805b7ecd3870bdb5, so I wonder if we miss something. ---------------------------------------- Bug #18250: Anonymous variables seem to break `Ractor.make_shareable` https://bugs.ruby-lang.org/issues/18250#change-94917 * Author: tenderlovemaking (Aaron Patterson) * Status: Closed * Priority: Normal * ruby -v: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin20] * Backport: 2.7: DONTNEED, 3.0: REQUIRED ---------------------------------------- The following code breaks with a strange error: ```ruby def foo(*); ->{ super };end Ractor.make_shareable(foo) # expected Symbol ``` Output: ``` [aaron@tc ~/g/ruby (master)]$ cat test.rb def foo(*); ->{ super };end Ractor.make_shareable(foo) # expected Symbol [aaron@tc ~/g/ruby (master)]$ ruby test.rb :816:in `make_shareable': wrong argument type false (expected Symbol) (TypeError) from test.rb:2:in `
' [aaron@tc ~/g/ruby (master)]$ ``` The reason is because the `*` parameter has no name, but Ractor tries to find the name so it can make an exception. I *expect* the above program to raise an `Ractor::IsolationError`, but instead it raises a `TypeError`. I've attached a patch that fixes this bug. ---Files-------------------------------- 0001-Give-params-a-name.patch (3.33 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: