Bug 553577 - Asynchronous code completion can lead to StackOverflowError
Summary: Asynchronous code completion can lead to StackOverflowError
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.12   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.15 M1   Edit
Assignee: Mickael Istria CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 531061
  Show dependency tree
 
Reported: 2019-11-28 07:01 EST by Mickael Istria CLA
Modified: 2021-03-13 07:41 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2019-11-28 07:01:15 EST
On https://git.eclipse.org/r/#/c/129022/ , it was identified that in some not-yet-clearly-determined cases, async completion can lead to a StackOverflowError

...
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.getSelectedProposal(CompletionProposalPopup.java:940)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.setProposals(CompletionProposalPopup.java:1180)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run(CompletionProposalPopup.java:376)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.getSelectedProposal(CompletionProposalPopup.java:940)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.setProposals(CompletionProposalPopup.java:1180)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run(CompletionProposalPopup.java:376)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.getSelectedProposal(CompletionProposalPopup.java:940)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.setProposals(CompletionProposalPopup.java:1180)
...


It was seen on Windows and Linux, using the Java async completion proposal of bug 531061.


Auditing the code, it seems like the "filterProposals" is always called in the meantime leading to this stack. The main goal seems to be reducing the cases when filterProposals is called in AsyncCompletionProposalPropup, and make sure it's not invoked too early.
Comment 1 Mickael Istria CLA 2019-12-10 16:38:26 EST
This is hopefully fixed.
Comment 3 Andrey Loskutov CLA 2019-12-12 02:15:20 EST
This causes regression in testAsyncFailureStackOverflow test.

https://download.eclipse.org/eclipse/downloads/drops4/I20191211-1805/testresults/html/org.eclipse.jface.text.tests_ep415I-unit-cen64-gtk3-java8_linux.gtk.x86_64_8.0.html

Failed to execute runnable (java.lang.NullPointerException)

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
at org.eclipse.swt.SWT.error(SWT.java:4720)
at org.eclipse.swt.SWT.error(SWT.java:4635)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:188)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4432)
at org.eclipse.jface.text.tests.util.DisplayHelper.driveEventQueue(DisplayHelper.java:126)
at org.eclipse.jface.text.tests.util.DisplayHelper.waitForCondition(DisplayHelper.java:63)
at org.eclipse.jface.text.tests.util.DisplayHelper.sleep(DisplayHelper.java:105)
at org.eclipse.jface.text.tests.contentassist.AsyncContentAssistTest.testAsyncFailureStackOverflow(AsyncContentAssistTest.java:68)

...

Caused by: java.lang.NullPointerException
at org.eclipse.jface.text.contentassist.AsyncCompletionProposalPopup.lambda$4(AsyncCompletionProposalPopup.java:241)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
... 72 more
Comment 4 Mickael Istria CLA 2019-12-12 02:28:38 EST
Thanks Andrey,
This is not a regression since the test was added as part of the commit, but it reveals a possible bug. I'll fix it soon.
Comment 5 Eclipse Genie CLA 2019-12-12 03:13:59 EST
New Gerrit change created: https://git.eclipse.org/r/154385
Comment 7 Mickael Istria CLA 2019-12-12 04:50:35 EST
Patch was merged and should prevent this NPE from happening.
I'm leaving this bug open for a few days to check test results and verify it did actually fix the tests. If anyone sees a failure before I do, please post here.
Comment 8 Mickael Istria CLA 2019-12-14 05:03:03 EST
3 builds happened since last patch was merged, and no failure was reported. Let'smark it foxed and reopen if needed.