diff --git a/test/-ext-/debug/test_debug.rb b/test/-ext-/debug/test_debug.rb index 3804714d0d..da66b1baf8 100644 --- a/test/-ext-/debug/test_debug.rb +++ b/test/-ext-/debug/test_debug.rb @@ -56,4 +56,20 @@ class TestDebug < Test::Unit::TestCase binds = inspector_in_eval binds_check binds, bug7635 end + + class MyRelation + include Enumerable + + def each + yield :each_entry + end + end + + def test_lazy_block + x = MyRelation.new.any? do + Bug::Debug.inspector + true + end + assert_equal true, x, '[Bug #15105]' + end end diff --git a/vm_backtrace.c b/vm_backtrace.c index 59340292cf..0493ed8c89 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -1202,6 +1202,9 @@ rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data) enum ruby_tag_type state; volatile VALUE MAYBE_UNUSED(result); + /* escape all env to heap */ + rb_vm_stack_to_heap(ec); + dbg_context.ec = ec; dbg_context.cfp = dbg_context.ec->cfp; dbg_context.backtrace = ec_backtrace_location_ary(ec, 0, 0);