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

Harden skip in Scanner #21607

Merged
merged 1 commit into from
Sep 20, 2024
Merged

Harden skip in Scanner #21607

merged 1 commit into from
Sep 20, 2024

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 18, 2024

After running metals for a while, I sometimes see a rogue java process at 100% even after I closed down sbt and vscode. With jstack I got the following stack trace:

java.lang.Thread.State: RUNNABLE

at dotty.tools.dotc.parsing.Scanners$Scanner.handleNewLine(Scanners.scala:613)

at dotty.tools.dotc.parsing.Scanners$Scanner.nextToken(Scanners.scala:396)

at dotty.tools.dotc.parsing.Scanners$Scanner.skip(Scanners.scala:312)

at dotty.tools.dotc.parsing.Parsers$Parser.skip(Parsers.scala:280)

at dotty.tools.dotc.parsing.Parsers$Parser.recur$2(Parsers.scala:376)

at dotty.tools.dotc.parsing.Parsers$Parser.statSepOrEnd(Parsers.scala:380)

It could be that the loop in skip gives two alternate offsets that would not bump the progress counter. I changed the loop so that it catches infinite looping conditions more robustly.

I sometimes see a rogue java process at 100% even after I closed down sbt and vscode.
With jstack I got the following stack trace:

    java.lang.Thread.State: RUNNABLE

	at dotty.tools.dotc.parsing.Scanners$Scanner.handleNewLine(Scanners.scala:613)

	at dotty.tools.dotc.parsing.Scanners$Scanner.nextToken(Scanners.scala:396)

	at dotty.tools.dotc.parsing.Scanners$Scanner.skip(Scanners.scala:312)

	at dotty.tools.dotc.parsing.Parsers$Parser.skip(Parsers.scala:280)

	at dotty.tools.dotc.parsing.Parsers$Parser.recur$2(Parsers.scala:376)

	at dotty.tools.dotc.parsing.Parsers$Parser.statSepOrEnd(Parsers.scala:380)

It could be that the loop in skip gives two alternate offsets that would not bump the progress counter.
I changed the loop so that it catches more looping conditions.
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I think we should be able to also catch such issues within metals, we do timeout on requests.

@hamzaremmal hamzaremmal merged commit 4293a45 into scala:main Sep 20, 2024
28 checks passed
@hamzaremmal hamzaremmal deleted the harden-skip branch September 20, 2024 08:54
WojciechMazur added a commit that referenced this pull request Dec 4, 2024
Backports #21607 to the 3.3.5.

PR submitted by the release tooling.
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.

3 participants