Skip to content

Commit

Permalink
removed diagnostics code and added some info to the overflow error
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Feb 29, 2024
1 parent 781cba1 commit b55cebf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
12 changes: 11 additions & 1 deletion src/org/rascalmpl/exceptions/RascalStackOverflowError.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public class RascalStackOverflowError extends RuntimeException {
private static final long serialVersionUID = -3947588548271683963L;
private final Environment deepestEnvironment;
private final AbstractAST currentAST;
private final int depth;

public RascalStackOverflowError(AbstractAST current, Environment deepest) {
public RascalStackOverflowError(AbstractAST current, Environment deepest, int depth) {
this.deepestEnvironment = deepest;
this.currentAST = current;
this.depth = depth;
}

public Throw makeThrow() {
Expand All @@ -43,4 +45,12 @@ public Throw makeThrow() {

return RuntimeExceptionFactory.stackOverflow(currentAST, trace);
}

public Environment getEnvironment() {
return deepestEnvironment;
}

public int getDepth() {
return depth;
}
}
13 changes: 1 addition & 12 deletions src/org/rascalmpl/interpreter/result/RascalFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.rascalmpl.ast.Statement;
import org.rascalmpl.ast.Type.Structured;
import org.rascalmpl.exceptions.ImplementationError;
import org.rascalmpl.exceptions.RascalStackOverflowError;
import org.rascalmpl.exceptions.RuntimeExceptionFactory;
import org.rascalmpl.interpreter.Accumulator;
import org.rascalmpl.interpreter.IEvaluator;
Expand Down Expand Up @@ -304,18 +305,6 @@ public Result<IValue> call(Type[] actualStaticTypes, IValue[] actuals, Map<Strin
storeMemoizedResult(actuals,keyArgValues, result);
return result;
}
catch (StackOverflowError e) {
// get a shallow stack trace because we don't have any stack room at the moment.
// StackTrace trace = new StackTrace();
// Environment env = eval.getCurrentEnvt();
// int max = 10;
// while (env != null && max-- > 0) {
// trace.add(env.getLocation(), env.getName());
// env = env.getCallerScope();
// }

throw new RuntimeException("hello");
}
}

matchers[0].initMatch(makeResult(actualStaticTypesTuple.getFieldType(0), actuals[0], ctx));
Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/semantics/dynamic/Expression.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public Result<IValue> interpret(IEvaluator<Result<IValue>> eval) {
}
catch (StackOverflowError e) {
// this should not use so much stack as to trigger another StackOverflowError
throw new RascalStackOverflowError(this, eval.getCurrentEnvt());
throw new RascalStackOverflowError(this, eval.getCurrentEnvt(), eval.getCallNesting());
}
return res;
}
Expand Down

0 comments on commit b55cebf

Please sign in to comment.