From: "rwstauner (Randy Stauner) via ruby-core" Date: 2026-08-10T17:08:36+00:00 Subject: [ruby-core:126365] [Ruby Bug#22240] Protect against SEGV caused by native extensions using rb_funcall between rb_protect and rb_jump_tag Issue #22240 has been updated by rwstauner (Randy Stauner). PR https://github.com/ruby/ruby/pull/18279 ---------------------------------------- Bug #22240: Protect against SEGV caused by native extensions using rb_funcall between rb_protect and rb_jump_tag https://bugs.ruby-lang.org/issues/22240#change-118494 * Author: rwstauner (Randy Stauner) * Status: Open * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- It's possible for native extensions do something like int state = 0; rb_protect(some_func, Qnil, &state); if (state) { rb_funcall(self, rb_intern("handler"), 0); rb_jump_tag(state); } If the ruby code in the rb_funcall has a rescue clause it will clear errinfo. When rb_jump_tag flows to hook_before_rewind with errinfo as Qnil it currently will SEGV. If I add a check to avoid the SEGV, the process then exits silently. If a native extension puts us in this state, the original message is gone. One thing we can do is detect this scenario and fabricate an exception. I have a PR up with a possible solution for this but am looking for feedback on the exception type and message or alternative suggestions for handling. I have reproduced this crash as far back as Ruby 3.3. -- 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/