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

Bug 369648

Summary: IndexOutOfBoundsException caused by concurrent threads should be caught in PHPSelectionEngine
Product: z_Archived Reporter: Natalia Bartol <natalia.bartol>
Component: PDTAssignee: PHP UI <php.ui-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ganoro, jacek.pospychala, kalin.a
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=368947
Whiteboard:
Attachments:
Description Flags
IndexOutOfBoundsException caught in PHPSelectionEngine - patch jacek.pospychala: iplog+

Description Natalia Bartol CLA 2012-01-25 07:42:54 EST
Build Identifier: 

Background thread may read source model at the same time when main thread modifies it. This may cause ArrayIndexOutOfBoundsException or StringIndexOutOfBoundsException. 

!ENTRY org.eclipse.php.core 4 10001 2012-01-24 17:12:32.919
!MESSAGE PHPCore plugin internal error
!STACK 0
java.lang.StringIndexOutOfBoundsException: String index out of range: 967786
	at java.lang.String.charAt(String.java:686)
	at org.eclipse.php.internal.core.util.text.PHPTextSequenceUtilities.readIdentifierStartIndex(PHPTextSequenceUtilities.java:375)
	at org.eclipse.php.internal.core.codeassist.PHPSelectionEngine.internalASTResolve(PHPSelectionEngine.java:234)
	at org.eclipse.php.internal.core.codeassist.PHPSelectionEngine.select(PHPSelectionEngine.java:100)
	at org.eclipse.dltk.internal.core.Openable.codeSelect(Openable.java:624)
	at org.eclipse.dltk.internal.core.Openable.codeSelect(Openable.java:636)
	at org.eclipse.dltk.internal.core.AbstractSourceModule.codeSelect(AbstractSourceModule.java:86)
	at org.eclipse.dltk.internal.core.AbstractSourceModule.codeSelect(AbstractSourceModule.java:77)
	at org.eclipse.php.internal.ui.actions.OpenTypeHierarchyAction.getSelectionModelElement(OpenTypeHierarchyAction.java:205)
	at org.eclipse.php.internal.ui.actions.OpenTypeHierarchyAction.isEnabled(OpenTypeHierarchyAction.java:155)
	at org.eclipse.php.internal.ui.actions.OpenTypeHierarchyAction.access$0(OpenTypeHierarchyAction.java:149)
	at org.eclipse.php.internal.ui.actions.OpenTypeHierarchyAction$1.run(OpenTypeHierarchyAction.java:117)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)





Reproducible: Sometimes

Steps to Reproduce:
Add new line of code and quickly remove it before background thread finishes reading source model.
Comment 1 Natalia Bartol CLA 2012-01-25 07:46:29 EST
This may happen as a result of moving OpenTypeHierarchyAction to non UI job: bug 368947.
Comment 2 Natalia Bartol CLA 2012-01-25 07:56:57 EST
Created attachment 210046 [details]
IndexOutOfBoundsException caught in PHPSelectionEngine - patch

Better IndexOutOfBoundsException handling in PHPSelectionEngine. As we are aware that concurrent source model access is allowed (and synchronization would badly affect editor's performance) internalASTResolve() returns null in case of exception thrown. This allows
Comment 3 Roy Ganor CLA 2012-01-26 06:44:44 EST
thanks!
Comment 4 Kalin CLA 2012-07-06 10:24:05 EDT
No longer reproduced.
Closing...

Kalin Yanev
kalin.a@zend.com