Skip to content

Rescue optimization over-optimizes rescue body with $! #4240

@headius

Description

@headius

Environment

Probably all JRuby releases since we started optimizing trivial rescues.

Expected Behavior

The exception in the following code should have a proper backtrace and not blow up in backtrace_locations.

$ jruby -e 'exception = (1 / 0) rescue $!; exception.backtrace_locations'
Unhandled Java exception: java.lang.NullPointerException
java.lang.NullPointerException: null
               backtrace_locations at org/jruby/RubyException.java:111

Actual Behavior

It doesn't have a backtrace and it blows up. $! is not being treated as an escape condition for the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions