ruby-changes:66582
From: eileencodes <ko1@a...>
Date: Thu, 24 Jun 2021 03:34:54 +0900 (JST)
Subject: [ruby-changes:66582] 31f4d26273 (master): Check type of instruction - can be INSN or ADJUST
https://git.ruby-lang.org/ruby.git/commit/?id=31f4d26273 From 31f4d262736c224a37e7c630a0790d40b11cdd57 Mon Sep 17 00:00:00 2001 From: eileencodes <eileencodes@g...> Date: Wed, 23 Jun 2021 13:28:22 -0400 Subject: 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@r...> --- compile.c | 1 + test/coverage/test_coverage.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/compile.c b/compile.c index c541711..a73a5be 100644 --- a/compile.c +++ b/compile.c @@ -3088,6 +3088,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal https://github.com/ruby/ruby/blob/trunk/compile.c#L3088 */ int stop_optimization = ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq) && + nobj->link.type == ISEQ_ELEMENT_INSN && nobj->insn_info.events; if (!stop_optimization) { INSN *pobj = (INSN *)iobj->link.prev; diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb index a80e333..22557bd 100644 --- a/test/coverage/test_coverage.rb +++ b/test/coverage/test_coverage.rb @@ -760,4 +760,18 @@ class TestCoverage < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/coverage/test_coverage.rb#L760 foo { raise } rescue nil 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/