Project

General

Profile

Actions

Bug #18250

closed

Anonymous variables seem to break `Ractor.make_shareable`

Added by tenderlovemaking (Aaron Patterson) 3 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin20]
[ruby-core:105626]

Description

The following code breaks with a strange error:

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
<internal:ractor>:816:in `make_shareable': wrong argument type false (expected Symbol) (TypeError)
        from test.rb:2:in `<main>'
[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) 0001-Give-params-a-name.patch tenderlovemaking (Aaron Patterson), 10/13/2021 12:40 AM
Actions #1

Updated by tenderlovemaking (Aaron Patterson) 3 months ago

  • File deleted (0001-Give-params-a-name.patch)

Updated by nobu (Nobuyoshi Nakada) 3 months ago

That is not enough.

$ ./ruby -v -e 'def foo((x, y)) -> {super}; end' -e 'Ractor.make_shareable(foo(nil))'
ruby 3.1.0dev (2021-10-13T02:03:39Z master e309d0260b) [x86_64-darwin19]
last_commit=Give `*` params a name
<internal:ractor>:816:in `make_shareable': wrong argument type false (expected Symbol) (TypeError)
    from -e:2:in `<main>'

Updated by nobu (Nobuyoshi Nakada) 3 months ago

https://github.com/nobu/ruby/tree/anonymous-lvar

commit 147cbbc4a648bf9671efec2604a00305ef74f2a6
Author:     Nobuyoshi Nakada <nobu@ruby-lang.org>
AuthorDate: 2021-10-13 14:25:34 +0900
Commit:     Nobuyoshi Nakada <nobu@ruby-lang.org>
CommitDate: 2021-10-13 16:46:16 +0900

    rb_id_serial_to_id: return unnamed ID as an internal ID

diff --git a/symbol.c b/symbol.c
index 94a751d5e3d..00044fd3902 100644
--- a/symbol.c
+++ b/symbol.c
@@ -486,7 +486,8 @@ rb_id_serial_to_id(rb_id_serial_t num)
 {
     if (is_notop_id((ID)num)) {
         VALUE sym = get_id_serial_entry(num, 0, ID_ENTRY_SYM);
-   return SYM2ID(sym);
+   if (sym) return SYM2ID(sym);
+   return ((ID)num << ID_SCOPE_SHIFT) | ID_INTERNAL | ID_STATIC_SYM;
     }
     else {
    return (ID)num;

Updated by byroot (Jean Boussier) 2 months ago

So following the last fixes Rails CI, as well as Shopify CI with regular ruby-head now passes.

However I noticed our ruby-head debug builds are running into an assertion error:

id_table.c:153: hash_table_raw_insert: Assertion 'key != 0' failed.

I replaced the assert with rb_bug to get a proper crash report:

/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:19: [BUG] hash_table_raw_insert key = 0
ruby 3.1.0dev (2021-11-12T15:59:33Z shopify 5ef4ca3264) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0067 p:---- s:0389 e:000388 CFUNC  :load_from_binary
c:0066 p:0017 s:0384 e:000383 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:19 [FINISH]
c:0065 p:---- s:0377 e:000376 CFUNC  :fetch
c:0064 p:0061 s:0369 e:000368 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:30
c:0063 p:0053 s:0362 e:000361 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:55 [FINISH]
c:0062 p:---- s:0356 e:000355 CFUNC  :require
c:0061 p:0011 s:0351 e:000350 BLOCK  /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23
c:0060 p:0069 s:0348 e:000347 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92
c:0059 p:0025 s:0336 e:000335 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22
c:0058 p:0057 s:0330 e:000329 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31
c:0057 p:0054 s:0322 e:000321 METHOD /tmp/bundle/ruby/3.1.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35
c:0056 p:0017 s:0316 e:000315 TOP    /app/lib/podding/routing.rb:6 [FINISH]
c:0055 p:---- s:0313 e:000312 CFUNC  :require
c:0054 p:0011 s:0308 e:000307 BLOCK  /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23
c:0053 p:0069 s:0305 e:000304 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92
c:0052 p:0025 s:0293 e:000292 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22
c:0051 p:0057 s:0287 e:000286 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31
c:0050 p:0054 s:0279 e:000278 METHOD /tmp/bundle/ruby/3.1.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35
c:0049 p:0085 s:0273 e:000272 TOP    /app/config/initializers/010_podding.rb:18 [FINISH]
c:0048 p:---- s:0270 e:000269 CFUNC  :load
c:0047 p:0035 s:0264 e:000263 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60
c:0046 p:0005 s:0254 e:000253 BLOCK  /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:667
c:0045 p:0033 s:0251 e:000250 METHOD /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/activesupport/lib/active_support/notifications.rb:209
c:0044 p:0020 s:0245 e:000244 METHOD /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:666
c:0043 p:0005 s:0240 e:000239 BLOCK  /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:620 [FINISH]
c:0042 p:---- s:0236 e:000235 CFUNC  :each
c:0041 p:0016 s:0232 e:000231 BLOCK  /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:619 [FINISH]
c:0040 p:---- s:0229 e:000228 CFUNC  :instance_exec
c:0039 p:0013 s:0224 e:000223 METHOD /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:32
c:0038 p:0017 s:0219 e:000218 BLOCK  /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:61
c:0037 p:0016 s:0215 e:000214 BLOCK  /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:228
c:0036 p:0004 s:0211 e:000210 BLOCK  /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:350
c:0035 p:0004 s:0207 e:000206 BLOCK  /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:422
c:0034 p:0098 s:0203 E:001640 METHOD /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:431
c:0033 p:0057 s:0191 E:0007d8 BLOCK  /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:421 [FINISH]
c:0032 p:---- s:0185 e:000184 CFUNC  :each
c:0031 p:0010 s:0181 e:000180 METHOD /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:50 [FINISH]
c:0030 p:---- s:0175 e:000174 CFUNC  :call
c:0029 p:0067 s:0170 E:000f20 METHOD /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:415
c:0028 p:0031 s:0158 E:0010e8 BLOCK  /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:349 [FINISH]
c:0027 p:---- s:0154 e:000153 CFUNC  :each
c:0026 p:---- s:0151 e:000150 CFUNC  :call
c:0025 p:0029 s:0147 E:001e40 METHOD /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:347
c:0024 p:0032 s:0139 E:0019b0 METHOD /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:226
c:0023 p:0033 s:0133 e:000132 METHOD /usr/local/ruby/lib/ruby/3.1.0/tsort.rb:205
c:0022 p:0019 s:0126 E:001950 METHOD /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:60
c:0021 p:0021 s:0120 e:000119 METHOD /tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/application.rb:369
c:0020 p:0019 s:0115 e:000114 TOP    /app/config/environment.rb:8 [FINISH]
c:0019 p:---- s:0112 e:000111 CFUNC  :require
c:0018 p:0011 s:0107 e:000106 BLOCK  /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23
c:0017 p:0069 s:0104 e:000103 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92
c:0016 p:0025 s:0092 e:000091 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22
c:0015 p:0057 s:0086 e:000085 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31
c:0014 p:0047 s:0078 e:000077 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54
c:0013 p:0005 s:0071 e:000070 TOP    /app/test/support/application_test_case.rb:4 [FINISH]
c:0012 p:---- s:0068 e:000067 CFUNC  :require
c:0011 p:0011 s:0063 e:000062 BLOCK  /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23
c:0010 p:0069 s:0060 e:000059 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92
c:0009 p:0025 s:0048 e:000047 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22
c:0008 p:0057 s:0042 e:000041 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31
c:0007 p:0047 s:0034 e:000033 METHOD /tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54
c:0006 p:0006 s:0027 e:000026 BLOCK  /app/test/test_helper.rb:8
c:0005 p:0062 s:0024 e:000023 METHOD /app/test/support/core_ci.rb:29
c:0004 p:0028 s:0017 e:000016 TOP    /app/test/test_helper.rb:7 [FINISH]
c:0003 p:---- s:0014 e:000013 CFUNC  :require_relative
c:0002 p:0035 s:0009 E:001cd8 EVAL   ./bin/ci/write_test_names:13 [FINISH]
c:0001 p:0000 s:0003 E:000930 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
./bin/ci/write_test_names:13:in `<main>'
./bin/ci/write_test_names:13:in `require_relative'
/app/test/test_helper.rb:7:in `<top (required)>'
/app/test/support/core_ci.rb:29:in `step'
/app/test/test_helper.rb:8:in `block in <top (required)>'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `require_relative'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/app/test/support/application_test_case.rb:4:in `<main>'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `require_relative'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/app/config/environment.rb:8:in `<main>'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/application.rb:369:in `initialize!'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:347:in `call'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:347:in `each'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:415:in `each_strongly_connected_component_from'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:415:in `call'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:50:in `tsort_each_child'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:50:in `each'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/usr/local/ruby/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:61:in `block in run_initializers'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:32:in `run'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/initializable.rb:32:in `instance_exec'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:619:in `block in <class:Engine>'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:619:in `each'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:666:in `load_config_initializer'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/activesupport/lib/active_support/notifications.rb:209:in `instrument'
/tmp/bundle/ruby/3.1.0/bundler/gems/rails-016f6c850c0c/railties/lib/rails/engine.rb:667:in `block in load_config_initializer'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
/app/config/initializers/010_podding.rb:18:in `<main>'
/tmp/bundle/ruby/3.1.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/app/lib/podding/routing.rb:6:in `<main>'
/tmp/bundle/ruby/3.1.0/gems/zeitwerk-2.5.1/lib/zeitwerk/kernel.rb:35:in `require'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:55:in `load_iseq'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:30:in `fetch'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:30:in `fetch'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:19:in `storage_to_output'
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:19:in `load_from_binary'

-- C level backtrace information -------------------------------------------
/usr/local/ruby/bin/ruby(rb_print_backtrace+0x11) [0x55830558a008] vm_dump.c:759
/usr/local/ruby/bin/ruby(rb_vm_bugreport) vm_dump.c:1045
/usr/local/ruby/bin/ruby(bug_report_end+0x0) [0x5583053bdf5f] error.c:797
/usr/local/ruby/bin/ruby(rb_bug_without_die) error.c:797
/usr/local/ruby/bin/ruby(die+0x0) [0x5583053a1680] error.c:805
/usr/local/ruby/bin/ruby(rb_bug) error.c:807
/usr/local/ruby/bin/ruby(rb_thread_fetch+0x0) [0x5583053aad53] id_table.c:154
/usr/local/ruby/bin/ruby(ibf_load_outer_variables+0xb5) [0x5583055eae06] compile.c:11587
/usr/local/ruby/bin/ruby(ibf_load_iseq_each) compile.c:11852
/usr/local/ruby/bin/ruby(rb_ibf_load_iseq_complete) compile.c:12745
/usr/local/ruby/bin/ruby(ibf_load_iseq+0xb0) [0x5583055ee0a0] compile.c:12800
/usr/local/ruby/bin/ruby(ibf_load_code+0x209) [0x5583055ecbb9] compile.c:11168
/usr/local/ruby/bin/ruby(ibf_load_iseq_each) compile.c:11863
/usr/local/ruby/bin/ruby(rb_ibf_load_iseq_complete) compile.c:12745
/usr/local/ruby/bin/ruby(ibf_load_iseq+0xb0) [0x5583055ee0a0] compile.c:12800
/usr/local/ruby/bin/ruby(ibf_load_code+0x209) [0x5583055ecbb9] compile.c:11168
/usr/local/ruby/bin/ruby(ibf_load_iseq_each) compile.c:11863
/usr/local/ruby/bin/ruby(rb_ibf_load_iseq_complete) compile.c:12745
/usr/local/ruby/bin/ruby(ibf_load_iseq+0xb0) [0x5583055ee0a0] compile.c:12800
/usr/local/ruby/bin/ruby(ibf_load_code+0x209) [0x5583055ecbb9] compile.c:11168
/usr/local/ruby/bin/ruby(ibf_load_iseq_each) compile.c:11863
/usr/local/ruby/bin/ruby(rb_ibf_load_iseq_complete) compile.c:12745
/usr/local/ruby/bin/ruby(ibf_load_iseq+0xb0) [0x5583055ee0a0] compile.c:12800
/usr/local/ruby/bin/ruby(ibf_load_code+0x209) [0x5583055ecbb9] compile.c:11168
/usr/local/ruby/bin/ruby(ibf_load_iseq_each) compile.c:11863
/usr/local/ruby/bin/ruby(rb_ibf_load_iseq_complete) compile.c:12745
/usr/local/ruby/bin/ruby(ibf_load_iseq+0xb0) [0x5583055ee0a0] compile.c:12800
/usr/local/ruby/bin/ruby(ibf_load_code+0x209) [0x5583055ecbb9] compile.c:11168
/usr/local/ruby/bin/ruby(ibf_load_iseq_each) compile.c:11863
/usr/local/ruby/bin/ruby(rb_ibf_load_iseq_complete) compile.c:12745
/usr/local/ruby/bin/ruby(ibf_load_iseq+0xb0) [0x5583055ee0a0] compile.c:12800
/usr/local/ruby/bin/ruby(rb_iseq_ibf_load+0x57) [0x5583055ee197] compile.c:12906
/usr/local/ruby/bin/ruby(iseqw_s_load_from_binary+0x10) [0x558305418f40] iseq.c:3552
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x139) [0x558305573e79] insns.def:777
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(vm_call0_body+0x37e) [0x55830556d17e] vm_eval.c:192
/usr/local/ruby/bin/ruby(rb_funcallv_scope+0x1f6) [0x558305570bf6] vm_eval.c:86
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/bootsnap.so(prot_storage_to_output+0x6c) [0x7f771ff4bc3c] bootsnap.c:925
/usr/local/ruby/bin/ruby(rb_protect+0x111) [0x5583053c9cf1] eval.c:967
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/bootsnap.so(bs_storage_to_output+0x21) [0x7f771ff4c0a3] bootsnap.c:937
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/bootsnap.so(bs_fetch) bootsnap.c:772
/tmp/bundle/ruby/3.1.0/gems/bootsnap-1.9.1/lib/bootsnap/bootsnap.so(bs_rb_fetch) bootsnap.c:362
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x139) [0x558305573e79] insns.def:777
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(vm_call0_body+0x37e) [0x55830556d17e] vm_eval.c:192
/usr/local/ruby/bin/ruby(rb_vm_call0+0xf5) [0x55830556daa5] vm_eval.c:57
/usr/local/ruby/bin/ruby(rb_vm_call_kw+0x1e) [0x55830556f378] vm_eval.c:295
/usr/local/ruby/bin/ruby(rb_check_funcall_default_kw) vm_eval.c:678
/usr/local/ruby/bin/ruby(RB_IMMEDIATE_P+0x0) [0x55830541e77a] iseq.c:946
/usr/local/ruby/bin/ruby(RB_SPECIAL_CONST_P) ./include/ruby/internal/special_consts.h:262
/usr/local/ruby/bin/ruby(rb_iseq_load_iseq) iseq.c:948
/usr/local/ruby/bin/ruby(load_iseq_eval+0x9) [0x5583054263a5] load.c:644
/usr/local/ruby/bin/ruby(require_internal) load.c:1128
/usr/local/ruby/bin/ruby(rb_require_string+0x38) [0x5583054265c2] load.c:1219
/usr/local/ruby/bin/ruby(rb_f_require) load.c:900
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_call_method_each_type+0x7d) [0x55830557c2fd] vm_insnhelper.c:3542
/usr/local/ruby/bin/ruby(vm_call_alias+0x9e) [0x55830557d97e] vm_insnhelper.c:3178
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x139) [0x558305573e79] insns.def:777
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(load_iseq_eval+0xa) [0x5583054263e6] load.c:656
/usr/local/ruby/bin/ruby(require_internal) load.c:1128
/usr/local/ruby/bin/ruby(rb_require_string+0x38) [0x5583054265c2] load.c:1219
/usr/local/ruby/bin/ruby(rb_f_require) load.c:900
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_call_method_each_type+0x7d) [0x55830557c2fd] vm_insnhelper.c:3542
/usr/local/ruby/bin/ruby(vm_call_alias+0x9e) [0x55830557d97e] vm_insnhelper.c:3178
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x139) [0x558305573e79] insns.def:777
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(raise_load_if_failed+0x0) [0x558305424c3e] load.c:656
/usr/local/ruby/bin/ruby(rb_load_internal) load.c:716
/usr/local/ruby/bin/ruby(rb_f_load) load.c:788
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_call_method_each_type+0x7d) [0x55830557c2fd] vm_insnhelper.c:3542
/usr/local/ruby/bin/ruby(vm_call_alias+0x9e) [0x55830557d97e] vm_insnhelper.c:3178
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x139) [0x558305573e79] insns.def:777
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(rb_yield+0x3f9) [0x55830557fbd9] vm.c:1298
/usr/local/ruby/bin/ruby(RB_BUILTIN_TYPE+0x0) [0x55830559e0c5] array.c:2522
/usr/local/ruby/bin/ruby(rbimpl_RB_TYPE_P_fastpath) ./include/ruby/internal/value_type.h:351
/usr/local/ruby/bin/ruby(RB_TYPE_P) ./include/ruby/internal/value_type.h:378
/usr/local/ruby/bin/ruby(Check_Type) ./include/ruby/internal/value_type.h:434
/usr/local/ruby/bin/ruby(rb_array_len) ./include/ruby/internal/core/rarray.h:300
/usr/local/ruby/bin/ruby(rb_ary_each) array.c:2521
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x1b8) [0x558305573ef8] insns.def:758
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(yield_under+0x264) [0x558305581004] vm.c:1425
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x1b8) [0x558305573ef8] insns.def:758
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(rb_yield+0x3f9) [0x55830557fbd9] vm.c:1298
/usr/local/ruby/bin/ruby(RB_BUILTIN_TYPE+0x0) [0x55830559e0c5] array.c:2522
/usr/local/ruby/bin/ruby(rbimpl_RB_TYPE_P_fastpath) ./include/ruby/internal/value_type.h:351
/usr/local/ruby/bin/ruby(RB_TYPE_P) ./include/ruby/internal/value_type.h:378
/usr/local/ruby/bin/ruby(Check_Type) ./include/ruby/internal/value_type.h:434
/usr/local/ruby/bin/ruby(rb_array_len) ./include/ruby/internal/core/rarray.h:300
/usr/local/ruby/bin/ruby(rb_ary_each) array.c:2521
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x1b8) [0x558305573ef8] insns.def:758
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(vm_call0_body+0x37e) [0x55830556d17e] vm_eval.c:192
/usr/local/ruby/bin/ruby(rb_vm_call0+0xf5) [0x55830556daa5] vm_eval.c:57
/usr/local/ruby/bin/ruby(rb_method_call_pass_called_kw+0x9c) [0x558305485ecc] proc.c:2422
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x1b8) [0x558305573ef8] insns.def:758
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(rb_yield+0x3f9) [0x55830557fbd9] vm.c:1298
/usr/local/ruby/bin/ruby(RB_BUILTIN_TYPE+0x0) [0x55830559e0c5] array.c:2522
/usr/local/ruby/bin/ruby(rbimpl_RB_TYPE_P_fastpath) ./include/ruby/internal/value_type.h:351
/usr/local/ruby/bin/ruby(RB_TYPE_P) ./include/ruby/internal/value_type.h:378
/usr/local/ruby/bin/ruby(Check_Type) ./include/ruby/internal/value_type.h:434
/usr/local/ruby/bin/ruby(rb_array_len) ./include/ruby/internal/core/rarray.h:300
/usr/local/ruby/bin/ruby(rb_ary_each) array.c:2521
/usr/local/ruby/bin/ruby(vm_call0_cfunc_with_frame+0x6e) [0x55830556d01a] vm_eval.c:149
/usr/local/ruby/bin/ruby(vm_call0_cfunc) vm_eval.c:163
/usr/local/ruby/bin/ruby(vm_call0_body) vm_eval.c:196
/usr/local/ruby/bin/ruby(rb_vm_call0+0xf5) [0x55830556daa5] vm_eval.c:57
/usr/local/ruby/bin/ruby(rb_method_call_pass_called_kw+0x9c) [0x558305485ecc] proc.c:2422
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_call_method_each_type+0x7d) [0x55830557c2fd] vm_insnhelper.c:3542
/usr/local/ruby/bin/ruby(vm_call_method+0x11f) [0x55830557cdef] vm_insnhelper.c:3666
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x1b8) [0x558305573ef8] insns.def:758
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(load_iseq_eval+0xa) [0x5583054263e6] load.c:656
/usr/local/ruby/bin/ruby(require_internal) load.c:1128
/usr/local/ruby/bin/ruby(rb_require_string+0x38) [0x5583054265c2] load.c:1219
/usr/local/ruby/bin/ruby(rb_f_require) load.c:900
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_call_method_each_type+0x7d) [0x55830557c2fd] vm_insnhelper.c:3542
/usr/local/ruby/bin/ruby(vm_call_alias+0x9e) [0x55830557d97e] vm_insnhelper.c:3178
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x139) [0x558305573e79] insns.def:777
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(load_iseq_eval+0xa) [0x5583054263e6] load.c:656
/usr/local/ruby/bin/ruby(require_internal) load.c:1128
/usr/local/ruby/bin/ruby(rb_require_string+0x38) [0x5583054265c2] load.c:1219
/usr/local/ruby/bin/ruby(rb_f_require) load.c:900
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_call_method_each_type+0x7d) [0x55830557c2fd] vm_insnhelper.c:3542
/usr/local/ruby/bin/ruby(vm_call_alias+0x9e) [0x55830557d97e] vm_insnhelper.c:3178
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x139) [0x558305573e79] insns.def:777
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(load_iseq_eval+0xa) [0x5583054263e6] load.c:656
/usr/local/ruby/bin/ruby(require_internal) load.c:1128
/usr/local/ruby/bin/ruby(rb_require_string+0x35) [0x558305426663] load.c:1219
/usr/local/ruby/bin/ruby(rb_f_require_relative) load.c:919
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame+0x110) [0x558305569450] vm_insnhelper.c:3026
/usr/local/ruby/bin/ruby(vm_sendish+0x190) [0x558305563c40] vm_insnhelper.c:4652
/usr/local/ruby/bin/ruby(vm_exec_core+0x139) [0x558305573e79] insns.def:777
/usr/local/ruby/bin/ruby(rb_vm_exec+0xbc) [0x55830556b65c] vm.c:2205
/usr/local/ruby/bin/ruby(rb_ec_exec_node+0xc9) [0x5583053c4229] eval.c:280
/usr/local/ruby/bin/ruby(ruby_run_node+0x58) [0x5583053c8ed8] eval.c:321
/usr/local/ruby/bin/ruby(main+0x73) [0x5583053ba9a3] ./main.c:47

I'm not 100% certain it's still the same error, but it looks like it.

Updated by byroot (Jean Boussier) about 2 months ago

nobu (Nobuyoshi Nakada) the Shopify "monolith". I didn't have time to reduce it just yet, I'll hopefully have a smaller repro this week.

Updated by byroot (Jean Boussier) about 2 months ago

I reduced it to a small script:

iseq = RubyVM::InstructionSequence.compile(<<~RUBY)
  def transport_request(req, *)
    foo do
      super
    end
  end
RUBY

RubyVM::InstructionSequence.load_from_binary(iseq.to_binary)

Seems very similar to the original error.

Updated by byroot (Jean Boussier) about 2 months ago

It's very weird, def transport_request(req, *) fail the assertion, but def transport_request(a, *) doesn't. Maybe because req legitimately hash to 0?

Actions #10

Updated by byroot (Jean Boussier) about 2 months ago

  • Status changed from Open to Closed

Applied in changeset git|eb301d8aecf454681e78cd7ad6d027e67b121857.


Add an extra failing test case for [Bug #18250]

The parameter being called req specifically causes an assertion error:

Assertion failed: (key != 0), function hash_table_raw_insert, file id_table.c, line 153.

Renaming the parameter or removing the * doesn't reproduce.

Updated by byroot (Jean Boussier) about 2 months ago

This bug made it to the recently released ruby 3.0.3: https://github.com/Shopify/bootsnap/issues/378#issuecomment-977949971

Seems like the fix wasn't backported.

Updated by nagachika (Tomoyuki Chikanaga) about 2 months ago

  • Backport changed from 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN to 2.7: UNKNOWN, 3.0: REQUIRED

I think these commits are related. Please tell me if I overlook something.

334b69e5042f47f89c8780c1d7efa32d70c84786
ec657f44dca3b84fde2a0b3b66c4e0e74a4cdce8
54bda176c6f1274c2311b02badee34002e4ea10e
eb301d8aecf454681e78cd7ad6d027e67b121857
c14f230b26aa4f8abe9ecf3814cfebbe584d77c9

Updated by byroot (Jean Boussier) about 2 months ago

nagachika (Tomoyuki Chikanaga) sounds about right to me. Thank you!

Actions #14

Updated by byroot (Jean Boussier) about 2 months ago

  • Backport changed from 2.7: UNKNOWN, 3.0: REQUIRED to 2.7: DONTNEED, 3.0: REQUIRED

Updated by byroot (Jean Boussier) about 2 months ago

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 <RubyVM::InstructionSequence:<compiled>@/Users/byroot/src/github.com/Shopify/ruby/test/ruby/test_iseq.rb:1>@pc=25
watch out the C stack trace.
== disasm: #<ISeq:<compiled>@/Users/byroot/src/github.com/Shopify/ruby/test/ruby/test_iseq.rb:1 (1,0)-(4,3)> (catch: FALSE)
0000 opt_getinlinecache                     9, <is:0>                 (   1)[Li]
0003 putobject                              true
0005 getconstant                            :Class
0007 opt_setinlinecache                     <is:0>
0009 opt_getinlinecache                     18, <is:1>
0012 putobject                              true
0014 getconstant                            :String
0016 opt_setinlinecache                     <is:1>
0018 opt_send_without_block                 <calldata!mid:new, argc:1, ARGS_SIMPLE>
0020 putstring                              "foo"
0022 opt_send_without_block                 <calldata!mid:new, argc:1, ARGS_SIMPLE>
0024 dup
0025 opt_case_dispatch                      <cdhash>, 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:

  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.

Actions

Also available in: Atom PDF