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

This fixes problem #1920 with a failure to throw a StackOverflow exception in case of a real stack overflow in Java code. #1921

Merged
merged 9 commits into from
Nov 22, 2024

Conversation

jurgenvinju
Copy link
Member

@jurgenvinju jurgenvinju commented Feb 29, 2024

  • stackoverflow errors were not reported properly. Instead the
    interpreter triggered many more stackoverflow errors while trying to
    report on them.
  • fixed this by capturing the deepest overflow exception and wrapping
    the current runtime stack in a cheap exception object. This object is
    then thrown an caught by the REPL loop which prints the proper
    exception stack trace.
  • if any code catches StackOverflow on the rascal call stack, we convert the cheap exception to the expensive throw just-in-time.

* stackoverflow errors were not reported properly. Instead the
  interpreter triggered many more stackoverflow errors while trying to
  report on them.
* fixed this by capturing the deepest overflow exception and wrapping
  the current runtime stack in a cheap exception object. This object is
  then thrown an caught by the REPL loop which prints the proper
  exception stack trace.
* We lost the ability to catch a stackOverflow() exception in Rascal
  code with this. This is problematic since there are tools that use
  that (drAmbiguity) in case of expected eternal recursions. So for now
  this is PR and I would like to hear if anybody has ideas on how to fix
  this properly without loss of this important feature.
Copy link

codecov bot commented Feb 29, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 49%. Comparing base (edfb516) to head (5004ced).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/org/rascalmpl/semantics/dynamic/Statement.java 26% 8 Missing and 6 partials ⚠️
src/org/rascalmpl/repl/RascalInterpreterREPL.java 0% 3 Missing ⚠️
...rascalmpl/exceptions/RascalStackOverflowError.java 90% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              main   #1921   +/-   ##
=======================================
  Coverage       49%     49%           
- Complexity    6315    6323    +8     
=======================================
  Files          664     665    +1     
  Lines        59584   59616   +32     
  Branches      8640    8649    +9     
=======================================
+ Hits         29496   29515   +19     
- Misses       27877   27881    +4     
- Partials      2211    2220    +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@jurgenvinju jurgenvinju force-pushed the proper-stacktrace-for-recursion-overflow branch from d79b2f4 to d089ff6 Compare February 29, 2024 15:36
@jurgenvinju jurgenvinju changed the title This fixes #1920 but it has a backward compatibility problem. This fixes problem #1920 with a failure to throw a StackOverflow exception in case of a real stack overflow in Java code. Nov 21, 2024
@jurgenvinju
Copy link
Member Author

@BlackHart98 it took a while, but this is fixed now. Thanks again for your report.

@jurgenvinju jurgenvinju marked this pull request as ready for review November 22, 2024 08:44
@jurgenvinju jurgenvinju merged commit 5b9e319 into main Nov 22, 2024
7 checks passed
@jurgenvinju jurgenvinju deleted the proper-stacktrace-for-recursion-overflow branch November 22, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant