summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Thacker-Smith <[email protected]>2019-09-27 01:10:13 -0400
committerJeremy Evans <[email protected]>2023-12-28 08:58:21 -0800
commit2b96737636e1c96fedda83895ef32e19a914e310 (patch)
treedb427d1d7994824a49627e70cc7a9370eb8a0dcf
parente81a5453e3c76c4348da042d86debde7689254fe (diff)
Fix use of the rb_profile_frames start parameter
Previously, it was decrementing the start argument until it reached zero without actually changing the control frame pointer. [Bug #14607]
-rw-r--r--test/-ext-/debug/test_profile_frames.rb4
-rw-r--r--vm_backtrace.c7
2 files changed, 9 insertions, 2 deletions
diff --git a/test/-ext-/debug/test_profile_frames.rb b/test/-ext-/debug/test_profile_frames.rb
index b44b14d851..bd819266df 100644
--- a/test/-ext-/debug/test_profile_frames.rb
+++ b/test/-ext-/debug/test_profile_frames.rb
@@ -236,4 +236,8 @@ class TestProfileFrames < Test::Unit::TestCase
a
end;
end
+
+ def test_start
+ assert_equal Bug::Debug.profile_frames(0, 10).tap(&:shift), Bug::Debug.profile_frames(1, 9)
+ end
end
diff --git a/vm_backtrace.c b/vm_backtrace.c
index 6e9436f76a..409f71d320 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -1593,7 +1593,7 @@ thread_profile_frames(rb_execution_context_t *ec, int start, int limit, VALUE *b
// Skip dummy frame; see `rb_ec_partial_backtrace_object` for details
end_cfp = RUBY_VM_NEXT_CONTROL_FRAME(end_cfp);
- for (i=0; i<limit && cfp != end_cfp;) {
+ for (i=0; i<limit && cfp != end_cfp; cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) {
if (VM_FRAME_RUBYFRAME_P(cfp) && cfp->pc != 0) {
if (start > 0) {
start--;
@@ -1627,12 +1627,15 @@ thread_profile_frames(rb_execution_context_t *ec, int start, int limit, VALUE *b
else {
cme = rb_vm_frame_method_entry(cfp);
if (cme && cme->def->type == VM_METHOD_TYPE_CFUNC) {
+ if (start > 0) {
+ start--;
+ continue;
+ }
buff[i] = (VALUE)cme;
if (lines) lines[i] = 0;
i++;
}
}
- cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
}
return i;