Check type of instruction - can be INSN or ADJUST
If the type is ADJUST we don't want to treat it like an INSN so we have to check the type before reading from `insn_info.events`. [Bug #18001] [ruby-core:104371] Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
This commit is contained in:
parent
b29c48efc0
commit
31f4d26273
Notes:
git
2021-06-24 03:34:59 +09:00
@ -3088,6 +3088,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
|||||||
*/
|
*/
|
||||||
int stop_optimization =
|
int stop_optimization =
|
||||||
ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq) &&
|
ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq) &&
|
||||||
|
nobj->link.type == ISEQ_ELEMENT_INSN &&
|
||||||
nobj->insn_info.events;
|
nobj->insn_info.events;
|
||||||
if (!stop_optimization) {
|
if (!stop_optimization) {
|
||||||
INSN *pobj = (INSN *)iobj->link.prev;
|
INSN *pobj = (INSN *)iobj->link.prev;
|
||||||
|
@ -760,4 +760,18 @@ class TestCoverage < Test::Unit::TestCase
|
|||||||
foo { raise } rescue nil
|
foo { raise } rescue nil
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_coverage_with_asan
|
||||||
|
result = { :lines => [1, 1, 0, 0, nil, nil, nil] }
|
||||||
|
|
||||||
|
assert_coverage(<<~"end;", { lines: true }, result) # Bug #18001
|
||||||
|
class Foo
|
||||||
|
def bar
|
||||||
|
baz do |x|
|
||||||
|
next unless Integer == x
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user