Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 559197

Summary: Java content assist freezes Eclipse when used in a lambda (2019-12)
Product: [Eclipse Project] JDT Reporter: Sam Peters <eclipse-devel>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: jjohnstn, loskutov, stephan.herrmann, Vikas.Chandra
Version: 4.14   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=549855
Whiteboard:
Attachments:
Description Flags
Test case as pure java project none

Description Sam Peters CLA 2020-01-15 06:41:33 EST
Created attachment 281503 [details]
Test case as pure java project

Hi, while working with lambdas, Eclipse reproducably freezes while using the Java content assist in a lambda expression.

I attached a minimal, self-containing test case without any dependencies as pure java project that demonstrates the issue. Btw., I use OpenJDK 11.0.2 and observed the effect in both 2019-09 and 2019-12.

It would be nice to resolve this issue since each time Eclipse must be restarted (after waiting for some minutes without luck).

Thank you for helping, Sam
Comment 1 Andrey Loskutov CLA 2020-01-16 05:18:21 EST
Can reproduce on HEAD, but with I20200115-1800 we see an error dialog after few seconds that:

The 'org.eclipse.jdt.ui.JavaAllCompletionProposalComputer' proposal computer from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The extension took too long to return from the 'computeCompletionProposals()' operation.

After that Eclipse works.

jstacks created during the short time show this:

"main" #1 prio=6 os_prio=0 tid=0x00007ffff0058000 nid=0x9882 runnable [0x00007ffff7fc7000]
   java.lang.Thread.State: RUNNABLE
        at org.eclipse.jdt.internal.compiler.parser.Scanner.<init>(Scanner.java:186)
        at org.eclipse.jdt.internal.compiler.parser.Scanner.<init>(Scanner.java:317)
        at org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser.<init>(AbstractCommentParser.java:118)
        at org.eclipse.jdt.internal.compiler.parser.JavadocParser.<init>(JavadocParser.java:71)
        at org.eclipse.jdt.internal.codeassist.complete.CompletionJavadocParser.<init>(CompletionJavadocParser.java:61)
        at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.createJavadocParser(CompletionParser.java:5762)
        at org.eclipse.jdt.internal.compiler.parser.Parser.<init>(Parser.java:990)
        at org.eclipse.jdt.internal.codeassist.impl.AssistParser.<init>(AssistParser.java:135)
        at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.<init>(CompletionParser.java:191)
        at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.createSnapShotParser(CompletionParser.java:5566)
        at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.updateRecoveryState(CompletionParser.java:5723)
        at org.eclipse.jdt.internal.compiler.parser.Parser.resumeOnSyntaxError(Parser.java:13363)
        at org.eclipse.jdt.internal.codeassist.complete.CompletionParser.resumeOnSyntaxError(CompletionParser.java:5607)
        at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:11943)
        at org.eclipse.jdt.internal.codeassist.impl.AssistParser.parseBlockStatements(AssistParser.java:2028)
        at org.eclipse.jdt.internal.codeassist.impl.AssistParser.parseBlockStatements(AssistParser.java:1868)
        at org.eclipse.jdt.internal.codeassist.impl.Engine.parseBlockStatements(Engine.java:349)
        at org.eclipse.jdt.internal.codeassist.impl.Engine.parseBlockStatements(Engine.java:312)
        at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2250)
        at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:136)
        at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:366)
        at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:356)
        at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals(JavaCompletionProposalComputer.java:258)
        at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.computeCompletionProposals(JavaCompletionProposalComputer.java:220)
        at org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposalComputer.computeCompletionProposals(JavaTypeCompletionProposalComputer.java:66)
        at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:345)
        at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:340)
        at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:333)
        at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:289)
        at org.eclipse.jface.text.contentassist.ContentAssistant$2.lambda$0(ContentAssistant.java:2015)
        at org.eclipse.jface.text.contentassist.ContentAssistant$2$$Lambda$778/1413580852.accept(Unknown Source)
        at java.util.Collections$SingletonSet.forEach(Collections.java:4767)
        at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:2014)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
        at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:2011)
        at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:578)
        at org.eclipse.jface.text.contentassist.CompletionProposalPopup.lambda$0(CompletionProposalPopup.java:508)
        at org.eclipse.jface.text.contentassist.CompletionProposalPopup$$Lambda$777/162250297.run(Unknown Source)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
        at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:503)
        at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1825)
        at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:189)
        at org.eclipse.ui.texteditor.ContentAssistAction.lambda$0(ContentAssistAction.java:85)
        at org.eclipse.ui.texteditor.ContentAssistAction$$Lambda$770/1160685808.run(Unknown Source)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
        at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:84)
Comment 2 Andrey Loskutov CLA 2020-01-16 06:45:39 EST
Jeff, could it be related to changes in JavadocParser via bug 549855?
Comment 3 Stephan Herrmann CLA 2020-01-16 07:43:13 EST
(In reply to Andrey Loskutov from comment #1)
> Can reproduce on HEAD, but with I20200115-1800 we see an error dialog after
> few seconds that:
> 
> The 'org.eclipse.jdt.ui.JavaAllCompletionProposalComputer' proposal computer
> from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The
> extension took too long to return from the 'computeCompletionProposals()'
> operation.

Shouldn't that be accompanied with an exception entry in the log?
Comment 4 Andrey Loskutov CLA 2020-01-16 07:44:58 EST
(In reply to Stephan Herrmann from comment #3)
> (In reply to Andrey Loskutov from comment #1)
> > Can reproduce on HEAD, but with I20200115-1800 we see an error dialog after
> > few seconds that:
> > 
> > The 'org.eclipse.jdt.ui.JavaAllCompletionProposalComputer' proposal computer
> > from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The
> > extension took too long to return from the 'computeCompletionProposals()'
> > operation.
> 
> Shouldn't that be accompanied with an exception entry in the log?

That *was* the entire exception in the log :-)
Comment 5 Sam Peters CLA 2020-01-16 08:14:20 EST
(In reply to Stephan Herrmann from comment #3)
> (In reply to Andrey Loskutov from comment #1)
> ...
> Shouldn't that be accompanied with an exception entry in the log?

Where do I find the log? I get neither an error dialog nor a message in the "Error Log" view (now waiting for 5 minutes...).
Comment 6 Stephan Herrmann CLA 2020-01-16 08:15:32 EST
(In reply to Andrey Loskutov from comment #4)
> (In reply to Stephan Herrmann from comment #3)
> > (In reply to Andrey Loskutov from comment #1)
> > > Can reproduce on HEAD, but with I20200115-1800 we see an error dialog after
> > > few seconds that:
> > > 
> > > The 'org.eclipse.jdt.ui.JavaAllCompletionProposalComputer' proposal computer
> > > from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The
> > > extension took too long to return from the 'computeCompletionProposals()'
> > > operation.
> > 
> > Shouldn't that be accompanied with an exception entry in the log?
> 
> That *was* the entire exception in the log :-)

Sorry, yes. I confused the error scenarios (timeout vs. exception as the root cause). I can reproduce.

Two questions remaining:

(1) Why do we see the error dialog, after which Eclipse comes back to life, whereas Sam is left with a stuck IDE?

(2) Is this a performance problem or a true freeze (no progress, infinitely)?

Note that we previously observed parsing to get stuck during syntax recovery in the presence of lambda expressions. For reasons explained elsewhere this is one of the hardest nuts to crack from all code that I've seen.
Comment 7 Stephan Herrmann CLA 2020-01-16 08:28:37 EST
After internally increasing the timeout I succeeded to take a few more jstacks, which show only minor difference in the top 5 or so stack frames. Ergo, we indeed have the situation of the parser not making any progress.

*** This bug has been marked as a duplicate of bug 539685 ***
Comment 8 Sam Peters CLA 2020-01-16 08:43:56 EST
(In reply to Stephan Herrmann from comment #6)
> Two questions remaining:
> 
> (1) Why do we see the error dialog, after which Eclipse comes back to life,
> whereas Sam is left with a stuck IDE?
> 
> (2) Is this a performance problem or a true freeze (no progress, infinitely)?
> 
> Note that we previously observed parsing to get stuck during syntax recovery
> in the presence of lambda expressions. For reasons explained elsewhere this
> is one of the hardest nuts to crack from all code that I've seen.

To (1): I just asked my colleague to test this on its own laptop. Same configuration, same problem.

To (2): It's a true freeze. Waiting for minutes does not help and Eclipse won't be responsive in any way. Closing the program is the only option.

I'd like to ask question (3): Why does code completion stops at one time (your observation) and does not stop at another (our observation)? It seems that timeout detection won't work in my case.

I think that getting a timeout with no code suggestions is, of course, not that cool but after all there is often the workaround to copy and paste the object in question outside the lambda expression and try again. Whereas a stuck IDE is definitely a bigger problem...