Project

General

Profile

Actions

Bug #15578

closed

Missing TracePoint return event when a conditional is used before a rescue

Added by zetter (Chris Zetter) almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:91366]

Description

Hello, I've been using TracePoint on a Ruby on Rails project and noticed that the number of method 'return' events was less than the number of 'call' events. An example of a return event that isn't always logged (depending on inputs) is the _decrypt method - https://github.com/rails/rails/blob/v5.2.2/activesupport/lib/active_support/message_encryptor.rb#L183

I've made a simplified example based on this method. There are other methods that don't have exact same structure but show the same problem. I haven't yet been able to make reproducible examples for them.

Running the following code with TracePoint doesn't emit the 'return' event as expected:

def example
  1 if 1 == 1
rescue
end

example()

Here are the events that are logged using TracePoint:

[nil, :line]
[:example, :call]
[:example, :line]

I expect it log the return even from the example method:

[nil, :line]
[:example, :call]
[:example, :line]
[:example, :return]

I have attached a runnable example.

This bug looks like it was introduced between 2.5.3 and 2.6.0. It works as expected on 2.5.3, and it occurs on 2.6.0 and 2.6.1

I've also tried compiling the instructions without peephole optimisation on and the bug no longer occurs.


Files

example.rb (249 Bytes) example.rb zetter (Chris Zetter), 01/31/2019 04:16 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #15911: Missing TracePoint return event for ||=ClosedActions
Actions #1

Updated by zetter (Chris Zetter) almost 6 years ago

  • Description updated (diff)
Actions #2

Updated by zetter (Chris Zetter) almost 6 years ago

  • Description updated (diff)

Updated by wanabe (_ wanabe) almost 6 years ago

git bisect shows it is introduced by r63248.

Actions #4

Updated by nobu (Nobuyoshi Nakada) almost 6 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r66977.


Revert r63383, r63248 "compile.c: copy a short insn with leave"

When copying leave insn, TRACE also should be copied if it is
present, but this optimization is trivial and not worth the
complexity. [ruby-core:91366] [Bug #15578]

4cae5353c03009beb1e0a1619422072773580609
5afd479de63b6609ddcd1510da94d2c1ac384f7f

Actions #5

Updated by mame (Yusuke Endoh) over 5 years ago

  • Related to Bug #15911: Missing TracePoint return event for ||= added
Actions #6

Updated by mame (Yusuke Endoh) over 5 years ago

  • Backport changed from 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN to 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 5 years ago

  • Backport changed from 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: REQUIRED to 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: DONE

ruby_2_6 r67726 merged revision(s) 66977.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0