From: "jhawthorn (John Hawthorn) via ruby-core" Date: 2026-11-12T19:42:03+00:00 Subject: [ruby-core:127453] [Ruby Bug#22084] invokesuper from define_method in Ractor can call wrong super method or crash Issue #22084 has been updated by jhawthorn (John Hawthorn). Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: DONE This was backported to 4.0 back in June https://github.com/ruby/ruby/pull/17154 ---------------------------------------- Bug #22084: invokesuper from define_method in Ractor can call wrong super method or crash https://bugs.ruby-lang.org/issues/22084#change-119906 * Author: jhawthorn (John Hawthorn) * Status: Closed * Assignee: ractor * ruby -v: ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: DONE ---------------------------------------- `vm_search_super_method` has an odd behaviour where it allocates new callinfo (ci) and assigns it back to the iseq. All of our other method calls only reassign the callcache (cc). Because this CI is used from the iseq immediately after for method lookup or even later for the name in method_missing. ```ruby N = Integer(ENV.fetch("N", "1000000")) class Base def method_missing(mid, *) = mid end class Child < Base BODY = Ractor.shareable_proc { super() } define_method(:foo, &BODY) define_method(:bar, &BODY) end [:foo, :bar].map do |mid| Ractor.new(mid) do |mid| obj = Child.new N.times do got = obj.__send__(mid) raise "#{mid} returned #{got.inspect}" unless got == mid end end end.each(&:value) ``` This will eventually result in method_missing being called with the wrong name Another test also crashes on my arm-based M4 macbook pro. Which I think may be a memory ordering issue of the newly allocated callcache: ```ruby N = Integer(ENV.fetch("N", "1000000")) class Base def foo = :foo def bar = :bar end class Child < Base BODY = Ractor.shareable_proc { super() } define_method(:foo, &BODY) define_method(:bar, &BODY) end [:foo, :bar].map do |mid| Ractor.new(mid) do |mid| obj = Child.new N.times do got = obj.__send__(mid) raise "#{mid} returned #{got.inspect}" unless got == mid end end end.each(&:value) ``` https://github.com/ruby/ruby/pull/17127 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/