From e35c528d721d209ed8531b10b46c2ac725ea7bf5 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 17 Oct 2022 17:50:42 +0900 Subject: push dummy frame for loading process This patch pushes dummy frames when loading code for the profiling purpose. The following methods push a dummy frame: * `Kernel#require` * `Kernel#load` * `RubyVM::InstructionSequence.compile_file` * `RubyVM::InstructionSequence.load_from_binary` https://bugs.ruby-lang.org/issues/18559 --- vm_backtrace.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'vm_backtrace.c') diff --git a/vm_backtrace.c b/vm_backtrace.c index 3aae59bf68..12157ef707 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -37,10 +37,8 @@ inline static int calc_pos(const rb_iseq_t *iseq, const VALUE *pc, int *lineno, int *node_id) { VM_ASSERT(iseq); - VM_ASSERT(ISEQ_BODY(iseq)); - VM_ASSERT(ISEQ_BODY(iseq)->iseq_encoded); - VM_ASSERT(ISEQ_BODY(iseq)->iseq_size); - if (! pc) { + + if (pc == NULL) { if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_TOP) { VM_ASSERT(! ISEQ_BODY(iseq)->local_table); VM_ASSERT(! ISEQ_BODY(iseq)->local_table_size); @@ -53,6 +51,10 @@ calc_pos(const rb_iseq_t *iseq, const VALUE *pc, int *lineno, int *node_id) return 1; } else { + VM_ASSERT(ISEQ_BODY(iseq)); + VM_ASSERT(ISEQ_BODY(iseq)->iseq_encoded); + VM_ASSERT(ISEQ_BODY(iseq)->iseq_size); + ptrdiff_t n = pc - ISEQ_BODY(iseq)->iseq_encoded; VM_ASSERT(n <= ISEQ_BODY(iseq)->iseq_size); VM_ASSERT(n >= 0); @@ -1557,7 +1559,7 @@ rb_profile_frames(int start, int limit, VALUE *buff, int *lines) end_cfp = RUBY_VM_NEXT_CONTROL_FRAME(end_cfp); for (i=0; ipc != 0) { if (start > 0) { start--; continue; -- cgit v1.2.3