summaryrefslogtreecommitdiff
path: root/version.h
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-08-06 08:07:56 -0700
committernagachika <nagachika@ruby-lang.org>2021-08-08 12:59:45 +0900
commitc07545bbf82068f4fd92a5ccfa2b09bb96b39adb (patch)
tree49e38acf3fd6567b1c4ca636837d0529c6a999a0 /version.h
parentd6b8b37a2608a0fbb8bcfd10356bb25f9ebbe1fe (diff)
Fix multiple bugs in partial backtrace optimization
This fixes multiple bugs found in the partial backtrace optimization added in 3b24b79. These bugs occurs when passing a start argument to caller where the start argument lands on a iseq frame without a pc. Before this commit, the following code results in the same line being printed twice, both for the #each method. ``` def a; [1].group_by { b } end def b; puts(caller(2, 1).first, caller(3, 1).first) end a ``` After this commit and in Ruby 2.7, the lines are different, with the first line being for each and the second for group_by. Before this commit, the following code can either segfault or result in an infinite loop: ``` def foo caller_locations(2, 1).inspect # segfault caller_locations(2, 1)[0].path # infinite loop end 1.times.map { 1.times.map { foo } } ``` After this commit, this code works correctly. In terms of the implementation, this correctly skips iseq frames without pc that occur before the number of frames the caller requested to skip. This rewrites the algorithm used for handling the partial backtraces. It scans from the current frame outward to the earliest frame, until it has found the desired number of frames. It records that frame as the start frame. If needed, it continues scanning backwards until arg->prev_cfp is set, as that is needed to set the location of the first frame. Due to the fact that arg is a void pointer, it's not possible to check this directly, but this calls the iter_skip function in a situation where it knows it will set arg->prev_cfp, and then breaks out of the loop. Fixes [Bug #18053]
Diffstat (limited to 'version.h')
0 files changed, 0 insertions, 0 deletions