Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 425084 - [1.8] eclipse freeze while attempting auto-completion with a 'try' pattern in a lambda
Summary: [1.8] eclipse freeze while attempting auto-completion with a 'try' pattern in...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3.1   Edit
Hardware: PC Windows 7
: P3 critical (vote)
Target Milestone: BETA J8   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-08 08:54 EST by Maxime Romand CLA
Modified: 2018-08-04 11:22 EDT (History)
3 users (show)

See Also:


Attachments
Diff of two CPU tracing snapshots when hung (71.64 KB, image/png)
2014-01-31 21:49 EST, Timo Kinnunen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Romand CLA 2014-01-08 08:54:50 EST

    
Comment 1 Maxime Romand CLA 2014-01-08 09:05:33 EST
Hi,

I'm currently using the Eclipse JDT Patch for Java 8 Support(BETA) v1.0.0.v20140107-0103_BETA_JAVA8 with Eclipse Kepler SR1 20130919-0819

When a try to get the autocompletion (Ctrl + Space) after the pattern 'try' in a lamba in a SWT Listener (see the following code  where '|' represente the cursor of the editor) eclipse freeze and is not responding anymore. 


code :

import org.eclipse.swt.widgets.Listener;
...

public class Plop {
...
Public Listener getListener(){
return event -> {
try|(ctrl + Space )
};
}
Comment 2 Stephan Herrmann CLA 2014-01-08 15:00:14 EST
CompletionParser does not seem to make any progress, with lots of snapshot parsers being created etc. ...
Looks like the kind of magic that only Srikanth can master :)
Comment 3 Srikanth Sankaran CLA 2014-01-31 18:25:54 EST
I'll take a look at this this week. Thanks Maxime.
Comment 4 Timo Kinnunen CLA 2014-01-31 21:49:59 EST
Created attachment 239539 [details]
Diff of two CPU tracing snapshots when hung

This is an infinite loop trying to recover from a syntax error during diet parse but not making any further progress. 

I didn't understand where the actual error was, but a working workaround I found was to put System.currentTimeMillis() into a ThreadLocal guarded with a try-finally-block at the start of CompletionParser.dietParse and then checking the time in CompletionParser.initializeScanner and throwing OperationCanceledException if it went over a second or so.
Comment 5 Srikanth Sankaran CLA 2014-01-31 22:36:29 EST
(In reply to Timo Kinnunen from comment #4)
> Created attachment 239539 [details]
> Diff of two CPU tracing snapshots when hung
> 
> This is an infinite loop trying to recover from a syntax error during diet
> parse but not making any further progress. 
> 
> I didn't understand where the actual error was, 

I think the commit operation is incorrectly capturing the error state the 
LALR automaton enters into and all further rollbacks roll back to this bad
state.
Comment 6 Srikanth Sankaran CLA 2014-02-03 23:30:34 EST
Sorry about the freeze and sorry about the delay.

Fix and test released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=90c80d82832fd719fe60993fa6dd40696f0b049a

(In reply to Srikanth Sankaran from comment #5)

> I think the commit operation is incorrectly capturing the error state the 
> LALR automaton enters into and all further rollbacks roll back to this bad
> state.

Yep. Fix is trivial. Ensure that only kosher states are committed at checkpoints.

(In reply to Timo Kinnunen from comment #4)

> I didn't understand where the actual error was, but a working workaround I
> found was to put System.currentTimeMillis() into a ThreadLocal guarded with
> a try-finally-block at the start of CompletionParser.dietParse and then
> checking the time in CompletionParser.initializeScanner and throwing
> OperationCanceledException if it went over a second or so.

I'll consider this for a second line of defense and work on a patch. You
shouldn't need a thread local - instance field should be good enough.
Comment 7 Srikanth Sankaran CLA 2014-02-04 07:36:31 EST
(In reply to Srikanth Sankaran from comment #6)

> I'll consider this for a second line of defense and work on a patch. You
> shouldn't need a thread local - instance field should be good enough.

I hooked up the CompletionParser infrastructure into the canonical of scheme
of things i.e IProgressMonitor that the CompletionEngine already tracks:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=7dbc472feab6f8985cd72052d6eaace52c7ea562
Comment 8 ANIRBAN CHAKRABORTY CLA 2014-02-24 15:05:46 EST
Verified as working for Eclipse + Java 8 RC1 using Kepler SR1 + Eclipse Java Development Tools Patch for Java 8 Support (BETA) 1.0.0.v20140220-2054