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

Analyzer hang on incomplete code "Future<List<>>" #44477

Closed
DanTup opened this issue Dec 15, 2020 · 3 comments
Closed

Analyzer hang on incomplete code "Future<List<>>" #44477

DanTup opened this issue Dec 15, 2020 · 3 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-front-end Use area-front-end for front end / CFE / kernel format related issues. P2 A bug or feature request we're likely to work on

Comments

@DanTup
Copy link
Collaborator

DanTup commented Dec 15, 2020

This might be the same as #34850, but it seemed like that was believed to be fixed so I'm raising a new issue (feel free to close as a dupe if so). This was reported in Dart-Code/Dart-Code#2865 (comment) and I can reproduce it on the latest nightly and it appears to get the analysis server stuck in an infinite loop.

I'm testing with the code:

Future<List<>>

I put it into an arbitrary test ('analysis_Server/test/lsp/format_test.dart'):

@soloTest
Future<void> test_danny() async {
  const contents = '''
Future<List<>>
''';
  await initialize();
  await openFile(mainFileUri, contents);

  await formatDocument(mainFileUri.toString());
}

The test doesn't fail, but this error occurs asynchronously:

Screenshot 2020-12-15 at 15 13 13

It's throwing here because of the assert, but when you reproduce it in a normal release build it appears to get the server stuck in an infinite loop (edit: if I run the same test without asserts from the command, it does indeed get stuck in a loop).

@bwilkerson @scheglov

@bwilkerson
Copy link
Member

@jensjoha This appears to be a parser issue. I suspect that the assert is being thrown because the endToken at that point is >> rather than >. We should also try to understand why there's an infinite loop when asserts are disabled and ensure that there aren't other conditions that would trigger the same behavior.

@scheglov The fact that the test passes and the assertion exception is thrown asynchronously is also concerning. It suggests that we might be missing an await somewhere (or perhaps an exception handler on a future).

@DanTup
Copy link
Collaborator Author

DanTup commented Dec 15, 2020

The fact that the test passes and the assertion exception is thrown asynchronously is also concerning.

I probably described that badly. This is because the code causing the error is not part of the formatting (which I was calling in the test to trigger this), but rather it occurs in the declarations code that runs outside of the format request (as part of the analysis that's running "in the background", triggered by starting the server).

@franklinyow franklinyow added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Dec 15, 2020
@jensjoha
Copy link
Contributor

jensjoha commented Dec 16, 2020

This is basically a duplicate of #42229 which I tried to fix with https://dart-review.googlesource.com/c/sdk/+/150521 back in June (but which was never landed because of #42258) --- I'll try to revive that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-front-end Use area-front-end for front end / CFE / kernel format related issues. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

5 participants