Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of exceptions raised inside TracePoint :call handling #4578

Closed

Conversation

jeremyevans
Copy link
Contributor

Previously, exceptions raised inside a TracePoint :call handler could
be handled by a rescue clause inside the method. However, TracePoint
:call handling should occur before the body of the method is executed.
Exceptions in TracePoint :call handling should be treated similarly to
exceptions raised when getting default values for arguments, and not
be rescued by exception handlers inside the method.

This fixes the issue by inserting a nop during rescue compilation, so
the start of the rescue catch table will definitely be after TracePoint
:call handling. It also works if you insert a nop during method
compilation, but I think it is better to make rescue handling slower
than than making method calling slower. Possibly this nop could be
optimized out in cases where it is not needed, but I was not able to
figure out how to do that. Hopefully someone with more knowledge of
the compiler will be able to do so.

Fixes [Bug #14479]

This apparently causes a failure in the typeprof tests, though I'm not sure
why that is.

Previously, exceptions raised inside a TracePoint :call handler could
be handled by a rescue clause inside the method.  However, TracePoint
:call handling should occur before the body of the method is executed.
Exceptions in TracePoint :call handling should be treated similarly to
exceptions raised when getting default values for arguments, and not
be rescued by exception handlers inside the method.

This fixes the issue by inserting a nop during rescue compilation, so
the start of the rescue catch table will definitely be after TracePoint
:call handling.  It also works if you insert a nop during method
compilation, but I think it is better to make rescue handling slower
than than making method calling slower.  Possibly this nop could be
optimized out in cases where it is not needed, but I was not able to
figure out how to do that.  Hopefully someone with more knowledge of
the compiler will be able to do so.

Fixes [Bug #14479]
@jeremyevans jeremyevans requested a review from mame June 16, 2021 23:36
@ioquatix
Copy link
Member

Nice work, looks like a tricky issue!

@mame mame requested a review from ko1 September 14, 2021 01:32
@mame
Copy link
Member

mame commented Sep 14, 2021

I don't know what is a correct behavior when an exception is raised in a TracePoint hook. I re-assigned this PR to @ko1.

The failure of TypeProf is not a big deal. I will be happy to change the test if this change is accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants