Bug #22072
closed[BUG] should have cvar cache entry
Description
Hi! I have a CI build for my project that runs on Ruby 4.0.4, and it has recently started sometimes segfaulting with this error: "".
I have seen failures in two different spots:
-
In the middle of tests:
/home/runner/work/graphql-ruby/graphql-ruby/vendor/bundle/ruby/4.0.0/gems/liquid-4.0.4/lib/liquid/strainer.rb:43: [BUG] should have cvar cache entry ruby 4.0.4 (2026-05-12 revision b89eb1bcbf) +PRISM [x86_64-linux]https://github.com/rmosolgo/graphql-ruby/actions/runs/25750012675/job/75623535379
-
At the very beginning of the suite:
# Running tests with run options --seed 45415: /home/runner/work/graphql-ruby/graphql-ruby/spec/graphql/dataloader_spec.rb:1515: warning: Scheduler should implement #fiber_interrupt /home/runner/work/graphql-ruby/graphql-ruby/spec/graphql/schema/ractor_shareable_spec.rb:54: warning: Ractor API is experimental and may change in future versions of Ruby. /home/runner/work/graphql-ruby/graphql-ruby/vendor/bundle/ruby/4.0.0/gems/railties-8.1.3/lib/rails/generators.rb:27: [BUG] should have cvar cache entry ruby 4.0.4 (2026-05-12 revision b89eb1bcbf) +PRISM [x86_64-linux]https://github.com/rmosolgo/graphql-ruby/actions/runs/25922299759/job/76194216570
I have attached the full crash messages to this issue.
I don't have any guesses what to do next with these errors, but I thought I'd report them in case they're helpful. I'm happy to debug with my project if there's anything I can do to help. For now, I can get it to pass by re-running the build. Thanks!
Robert
Files
Updated by peterzhu2118 (Peter Zhu) 4 days ago
- Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: DONTNEED, 3.4: DONTNEED, 4.0: REQUIRED
Thank you for this bug report. Using the seed in the crashing runs you have linked, I was able to reliably reproduce the issue. I was able to create a minimal reproduction and have a fix in this PR.
Updated by byroot (Jean Boussier) 4 days ago
- Related to Bug #21952: Ruby::Box double free at process exit when `fiddle/import` is required in multiple boxes added
Updated by peterzhu2118 (Peter Zhu) 3 days ago
- Status changed from Open to Closed
Applied in changeset git|6bc1aa31ccf39837bb0678da093b82f86a6534eb.
[Bug #22072] Fix rb_cvar_set for multi-Ractor
rb_cvar_set breaks the RCLASS_CVC_TBL because it creates a new cvc_tbl but
forgets to copy the contents over. This causes the following script to
crash:
r = Ractor.new {}
module Foo
def self.foo = @@foo
end
Foo.class_variable_set(:@@foo, nil)
Foo.class_variable_set(:@@bar, nil)
puts Foo.foo
Crashes with:
test.rb:4: [BUG] should have cvar cache entry
ruby 4.1.0dev (2026-05-16T21:11:21Z define-obj-has-suf.. 642cfc59a7) +PRISM [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0003 p:0003 s:0012 e:000011 l:y b:0001 r:(nil) METHOD test.rb:4
c:0002 p:0036 s:0008 E:001118 l:n b:---- r:(nil) EVAL test.rb:10 [FINISH]
c:0001 p:0000 s:0003 E:0013c0 l:y b:---- r:(nil) DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
test.rb:10:in '<main>'
test.rb:4:in 'foo'
-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 1
-- C level backtrace information -------------------------------------------
miniruby(rb_print_backtrace+0x24) [0x5701425120eb] vm_dump.c:1108
miniruby(rb_vm_bugreport+0x374) [0x5701425128f2] vm_dump.c:1456
miniruby(rb_bug_without_die_internal+0xa0) [0x5701422ad332] error.c:1107
miniruby(rb_bug+0xb5) [0x5701422ad4de] error.c:1125
miniruby(update_classvariable_cache+0xd1) [0x5701424d159c] vm_insnhelper.c:1501
miniruby(vm_getclassvariable+0xd1) [0x5701424d16e4] vm_insnhelper.c:1532
miniruby(vm_exec_core+0xfa6) [0x5701424e6fa9] insns.def:243
miniruby(rb_vm_exec+0x140) [0x570142504532] vm.c:2805
miniruby(rb_iseq_eval_main+0x3d) [0x5701425054c8] vm.c:3101
miniruby(rb_ec_exec_node+0x128) [0x5701422b914a] eval.c:284
miniruby(ruby_run_node+0x8d) [0x5701422b92be] eval.c:322
miniruby(rb_main+0x4c) [0x5701421ccd8e] main.c:42
miniruby(main+0x4b) [0x5701421ccdef] main.c:62