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

Make error reporting resilient to exception thrown while reporting #20158

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

smarter
Copy link
Member

@smarter smarter commented Apr 10, 2024

Previously the added test failed with 1 error reported but no actual error message printed, because a stack overflow is thrown while reporting the original error. This is then caught and handled to emit a RecursionOverflow error, but that second error is non-sensical and non-sensical errors are only printed if hasErrors returns false.

We fix this by deferring incrementing the error count (and therefore having hasErrors return true) until after having displayed the error. We also defer calling markReported otherwise the second error will also be suppressed. A similar change is necessary in our testing infrastructure to keep the error count is coherent.

smarter added 2 commits April 10, 2024 22:43
Previously the added test failed with `1 error reported` but no actual error
message printed, because a stack overflow is thrown while reporting the
original error. This is then caught and handled to emit a RecursionOverflow
error, but that second error is non-sensical and non-sensical errors are only
printed if `hasErrors` returns false.

We fix this by deferring incrementing the error count (and therefore having
`hasErrors` return true) until after having displayed the error. We also defer
calling `markReported` otherwise the second error will also be suppressed. A
similar change is necessary in our testing infrastructure to keep the error
count is coherent.
@bishabosha
Copy link
Member

bishabosha commented Apr 10, 2024

would this fix let me revert this commit? 5aca2da
i.e. any calls to report.echo seem to have no effect when SuspendException is immediately thrown afterwards

@smarter
Copy link
Member Author

smarter commented Apr 10, 2024

Hmm, I don't know but I would guess not.

@smarter smarter requested a review from odersky April 11, 2024 11:45
@odersky odersky merged commit dfff8f6 into scala:main Apr 11, 2024
19 checks passed
@odersky odersky deleted the resilient-reporting branch April 11, 2024 13:14
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
WojciechMazur added a commit that referenced this pull request Jul 5, 2024
…porting" to LTS (#21059)

Backports #20158 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
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.

4 participants