Skip to content
Permalink
Browse files
War of the wallpaper! I think my fix to remove bogus extra dynscope p…
…er simple eval

exposed that we somewhere pop off toplevel scope before the runtime shuts down.  To
counteract this I add back a bogus scope only for shutdown.  This is likely a bug
in that any capture lvars in at_exit blocks is likely lost (haven't tested), but
this makes mspec fast run without error for now.
  • Loading branch information
enebo committed Dec 18, 2014
1 parent a8e5323 commit 0f4adc34b63b47f88e113fb5ca2f95817ef8e30b
Showing with 15 additions and 0 deletions.
  1. +11 −0 core/src/main/java/org/jruby/Ruby.java
  2. +4 −0 core/src/main/java/org/jruby/runtime/ThreadContext.java
@@ -42,6 +42,7 @@
import org.jruby.compiler.Constantizable;
import org.jruby.compiler.NotCompilableException;
import org.jruby.ir.IRScriptBody;
import org.jruby.parser.StaticScope;
import org.objectweb.asm.util.TraceClassVisitor;

import jnr.constants.Constant;
@@ -3164,6 +3165,16 @@ public void tearDown(boolean systemExit) {
// clear out threadlocals so they don't leak
recursive = new ThreadLocal<Map<String, RubyHash>>();

ThreadContext context = getCurrentContext();

// FIXME: 73df3d230b9d92c7237d581c6366df1b92ad9b2b exposed no toplevel scope existing anymore (I think the
// bogus scope I removed was playing surrogate toplevel scope and wallpapering this bug). For now, add a
// bogus scope back for at_exit block run. This is buggy if at_exit is capturing vars.
if (!context.hasAnyScopes()) {
StaticScope topStaticScope = getStaticScopeFactory().newLocalScope(null);
context.pushScope(new ManyVarsDynamicScope(topStaticScope, null));
}

while (!atExitBlocks.empty()) {
RubyProc proc = atExitBlocks.pop();
try {
@@ -533,6 +533,10 @@ public static void popBacktrace(ThreadContext context) {
context.backtraceIndex--;
}

public boolean hasAnyScopes() {
return scopeIndex > -1;
}

/**
* Check if a static scope is present on the call stack.
* This is the IR equivalent of isJumpTargetAlive

0 comments on commit 0f4adc3

Please sign in to comment.