Skip to content

Commit

Permalink
Fixes #4467. Exception backtrace is nil when it should be present.
Browse files Browse the repository at this point in the history
We need to back off on this optimization in cases where the exception
list exists.  Statically, we cannot know if StandardError is really a builtin
one or it has been overridden.  Even beyond that we had no logic ensuring it
was even StandardError-based exception so we would kill backtraces that an
outer begin/rescue might want to catch and look at the backtrace.  Bare
rescues and rescue_mods still are fast which was the main motivation for
this optimization.
  • Loading branch information
enebo committed Feb 10, 2017
1 parent e66f638 commit 948554d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Expand Up @@ -3493,7 +3493,12 @@ private boolean canBacktraceBeRemoved(RescueNode rescueNode) {
if (RubyInstanceConfig.FULL_TRACE_ENABLED || !(rescueNode instanceof RescueModNode) &&
rescueNode.getElseNode() != null) return false;

Node body = rescueNode.getRescueNode().getBodyNode();
RescueBodyNode rescueClause = rescueNode.getRescueNode();

if (rescueClause.getOptRescueNode() != null) return false; // We will not handle multiple rescues
if (rescueClause.getExceptionNodes() != null) return false; // We cannot know if these are builtin or not statically.

Node body = rescueClause.getBodyNode();

// This optimization omits backtrace info for the exception getting rescued so we cannot
// optimize the exception variable.
Expand Down

0 comments on commit 948554d

Please sign in to comment.