diff options
-rw-r--r-- | error.c | 4 | ||||
-rw-r--r-- | test/ruby/test_require.rb | 15 |
2 files changed, 18 insertions, 1 deletions
@@ -1825,7 +1825,9 @@ name_err_init_attr(VALUE exc, VALUE recv, VALUE method) cfp = rb_vm_get_ruby_level_next_cfp(ec, cfp); rb_ivar_set(exc, id_name, method); err_init_recv(exc, recv); - if (cfp) rb_ivar_set(exc, id_iseq, rb_iseqw_new(cfp->iseq)); + if (cfp && VM_FRAME_TYPE(cfp) != VM_FRAME_MAGIC_DUMMY) { + rb_ivar_set(exc, id_iseq, rb_iseqw_new(cfp->iseq)); + } return exc; } diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index e124498531..49c771c33c 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -960,4 +960,19 @@ class TestRequire < Test::Unit::TestCase assert_nil($LOAD_PATH.resolve_feature_path("superkalifragilisticoespialidoso")) end end + + def test_require_with_public_method_missing + # [Bug #19793] + assert_separately(["-W0", "--disable-gems", "-rtempfile"], __FILE__, __LINE__, <<~RUBY) + GC.stress = true + + class Object + public :method_missing + end + + Tempfile.create(["empty", ".rb"]) do |file| + require file.path + end + RUBY + end end |