Bug 540763 - Syntax error causes eclipse to freeze
Summary: Syntax error causes eclipse to freeze
Status: CLOSED DUPLICATE of bug 539685
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.9   Edit
Hardware: PC Windows 10
: P3 major with 1 vote (vote)
Target Milestone: 4.20   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-04 21:17 EST by Larkin Lowrey CLA
Modified: 2023-06-02 11:50 EDT (History)
4 users (show)

See Also:


Attachments
Eclipse installation details (841.87 KB, text/plain)
2018-11-04 21:17 EST, Larkin Lowrey CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Larkin Lowrey CLA 2018-11-04 21:17:14 EST
Created attachment 276466 [details]
Eclipse installation details

I typed a line of java which was not syntactically correct and it caused my eclipse to freeze completely. Windows reported that it was "Not Responding" and the only thing I could do was kill it using TaskManager.

When I re-started eclipse the build would run to a certain percentage then gang there. All other operations were blocked since the build never completed.

The offending line was:

    stream.forEach((list::add);

Note that the parens do not match (one too many open paren).

I had to edit the java file outside of eclipse. With the typo fixed, eclipse starts and builds normally.

You can find a test-case @ https://github.com/llowrey/eclipse-freeze-test-case

Version: 2018-09 (4.9.0)
Build id: 20180917-1800
Comment 1 Stephan Herrmann CLA 2018-11-06 06:26:44 EST
I can reproduce. Thread "Compiler Processing Task" seems to have an infinite loop in 

Parser.parse() line: 11561	
Parser.parseExpression(char[], int, int, CompilationUnitDeclaration, boolean) line: 12239	
ReferenceExpression.copy() line: 152	
ReferenceExpression.cachedResolvedCopy(TypeBinding) line: 948	
ReferenceExpression.isCompatibleWith(TypeBinding, Scope) line: 1231	
PolyTypeBinding.isCompatibleWith(TypeBinding, Scope) line: 43	
BlockScope(Scope).parameterCompatibilityLevel(TypeBinding, TypeBinding, LookupEnvironment, boolean) line: 4917	
BlockScope(Scope).parameterCompatibilityLevel(MethodBinding, TypeBinding[], boolean) line: 4884	
BlockScope(Scope).computeCompatibleMethod(MethodBinding, TypeBinding[], InvocationSite, boolean) line: 867	
BlockScope(Scope).computeCompatibleMethod(MethodBinding, TypeBinding[], InvocationSite) line: 794	
BlockScope(Scope).findMethod0(ReferenceBinding, char[], TypeBinding[], InvocationSite, boolean) line: 1750	
BlockScope(Scope).findMethod(ReferenceBinding, char[], TypeBinding[], InvocationSite, boolean) line: 1651	
BlockScope(Scope).getMethod(TypeBinding, char[], TypeBinding[], InvocationSite) line: 2934	
MessageSend.findMethodBinding(BlockScope) line: 954	
MessageSend.resolveType(BlockScope) line: 775	
MessageSend(Expression).resolve(BlockScope) line: 1034	
Block.resolveUsing(BlockScope) line: 138	
TryStatement.resolve(BlockScope) line: 1189	
MethodDeclaration(AbstractMethodDeclaration).resolveStatements() line: 641	
MethodDeclaration.resolveStatements() line: 316	
MethodDeclaration(AbstractMethodDeclaration).resolve(ClassScope) line: 551	
TypeDeclaration.resolve() line: 1229	
TypeDeclaration.resolve(CompilationUnitScope) line: 1354	
CompilationUnitDeclaration.resolve() line: 656	
Compiler.process(CompilationUnitDeclaration, int) line: 892	
ProcessTaskManager.run() line: 145	
Thread.run() line: 844	


Other threads like "Text Viewer Hover Presenter" have the same problem.

Strangely it started OK, even completion worked, until I did Project > Clean. Even despite the infinite loop, I can continue to work in Eclipse. Just the build never finishes (so saving changes is blocked). Clean Exit is also blocked.
Comment 2 Stephan Herrmann CLA 2018-11-06 06:28:52 EST
To make the bug self-contained: this is the test case:

//---
package example;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;

public class TestCase
{
	public static void testCase(Path path) throws Exception
	{
		var list = new ArrayList<Path>();
		try (var stream = Files.newDirectoryStream(path))
		{
			stream.forEach((list::add);
		}
	}
}
//---
Comment 3 Manoj N Palat CLA 2019-02-11 03:59:46 EST
Bulk move out of 4.11
Comment 4 Jay Arthanareeswaran CLA 2019-05-20 02:35:07 EDT
Any workaround for this?
Comment 5 Stephan Herrmann CLA 2019-05-20 17:36:41 EDT
(In reply to Jay Arthanareeswaran from comment #4)
> Any workaround for this?

Don't write code with syntax errors? ;p

Or did you ask for some hack to brute-force abort the infinite parse?
Comment 6 Jay Arthanareeswaran CLA 2019-05-22 00:19:09 EDT
(In reply to Stephan Herrmann from comment #5)
> (In reply to Jay Arthanareeswaran from comment #4)
> > Any workaround for this?
> 
> Don't write code with syntax errors? ;p
> 
> Or did you ask for some hack to brute-force abort the infinite parse?

Sorry, I didn't look closely. I thought there was some content assist involved and that some incomplete code led to this issue. Please ignore this.
Comment 7 Manoj N Palat CLA 2019-08-27 01:04:58 EDT
Bulk move to 4.14
Comment 8 Stephan Herrmann CLA 2019-11-17 16:08:31 EST
Bulk move of unassigned bugs to 4.15
Comment 9 Stephan Herrmann CLA 2020-02-27 18:49:45 EST
Bulk move to 4.16
Comment 10 Stephan Herrmann CLA 2020-05-18 18:47:03 EDT
Bulk move of unassigned bugs to 4.17
Comment 11 Srikanth Sankaran CLA 2023-06-01 05:12:12 EDT
Not reproducible anymore on 4.28 RC1
Comment 12 Stephan Herrmann CLA 2023-06-01 08:49:58 EDT
(In reply to Srikanth Sankaran from comment #11)
> Not reproducible anymore on 4.28 RC1

Thanks for testing. With this I'll boldly declare this a duplicate of bug 539685.

Srikanth, fyi: in bug 539685 comment 29 f. I explained a significant change of strategy.

*** This bug has been marked as a duplicate of bug 539685 ***
Comment 13 Srikanth Sankaran CLA 2023-06-02 00:12:35 EDT
(In reply to Stephan Herrmann from comment #12)
> (In reply to Srikanth Sankaran from comment #11)
> > Not reproducible anymore on 4.28 RC1
> 
> Thanks for testing. With this I'll boldly declare this a duplicate of bug
> 539685.
> 
> Srikanth, fyi: in bug 539685 comment 29 f. I explained a significant change
> of strategy.
> 
> *** This bug has been marked as a duplicate of bug 539685 ***

Sorry, looks like you had to wage a decidedly non fun battle with the completion engine. I had a super clean design in 2014 Oct which I never committed to paper. You will have to take my word that it would have solved all our problems and would have been the cleanest most elegant implementation - with no proof for such claim. A la Fermat.
Comment 14 Stephan Herrmann CLA 2023-06-02 11:50:02 EDT
(In reply to Srikanth Sankaran from comment #13)
> (In reply to Stephan Herrmann from comment #12)
> > (In reply to Srikanth Sankaran from comment #11)
> > > Not reproducible anymore on 4.28 RC1
> > 
> > Thanks for testing. With this I'll boldly declare this a duplicate of bug
> > 539685.
> > 
> > Srikanth, fyi: in bug 539685 comment 29 f. I explained a significant change
> > of strategy.
> > 
> > *** This bug has been marked as a duplicate of bug 539685 ***
> 
> Sorry, looks like you had to wage a decidedly non fun battle with the
> completion engine.

"fun" is a relative concept :)  Indeed I was quite happy when in the end eclipse would no longer freeze..

and then I was battling not only with code from 2013/14, I had to make some changes to strategies defined well even before your time.

> I had a super clean design in 2014 Oct which I never
> committed to paper. You will have to take my word that it would have solved
> all our problems and would have been the cleanest most elegant
> implementation - with no proof for such claim. A la Fermat.

Time to print books with larger margins.