Bug 562436 - ASTParser.createBindings fails if Editor is Opened in Parallel
Summary: ASTParser.createBindings fails if Editor is Opened in Parallel
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.15   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-23 06:56 EDT by Christian Dietrich CLA
Modified: 2022-11-04 00:24 EDT (History)
3 users (show)

See Also:


Attachments
Sample Test Project (67.06 KB, application/zip)
2020-04-23 06:58 EDT, Christian Dietrich CLA
no flags Details
Updated version of test to avoid memory leak with progress service (5.20 KB, text/x-java)
2020-05-06 12:59 EDT, Christian Dietrich CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Dietrich CLA 2020-04-23 06:56:38 EDT
When ASTParser.createBindings is called for a type on a Thread/Job
and the Editor for the same file is opened/closed in parallel,
it can happen that createBindings returns a null binding due
the buffer is closed in org.eclipse.jdt.internal.core.CompilationUnit.getContents()


This is cause the buffer may be closed either by another Job/Thread doing the same createBindings

at org.eclipse.jdt.internal.core.Buffer.close(Buffer.java:116)
	at org.eclipse.jdt.internal.core.CompilationUnit.openBuffer(CompilationUnit.java:1231)
	at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:113)
	at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:270)
	at org.eclipse.jdt.internal.core.SourceRefElement.generateInfos(SourceRefElement.java:113)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:596)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:326)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:312)
	at org.eclipse.jdt.internal.core.SearchableEnvironment.find(SearchableEnvironment.java:184)
	at org.eclipse.jdt.internal.core.SearchableEnvironment.findType(SearchableEnvironment.java:478)
	at org.eclipse.jdt.internal.compiler.env.IModuleAwareNameEnvironment.findType(IModuleAwareNameEnvironment.java:101)
	at org.eclipse.jdt.internal.core.CancelableNameEnvironment.findType(CancelableNameEnvironment.java:53)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:299)
	at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:276)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:3463)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:3174)
	at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:57)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.internalResolveType(TypeReference.java:526)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:628)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:624)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.resolveTypeFor(SourceTypeBinding.java:2115)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.fields(SourceTypeBinding.java:1092)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.internalFaultInTypeForFieldsAndMethods(SourceTypeBinding.java:1060)
	at org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.faultInTypesForFieldsAndMethods(SourceTypeBinding.java:1056)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.faultInTypes(CompilationUnitScope.java:529)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:894)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:919)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:614)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:839)
	at org.eclipse.jdt.core.dom.ASTParser.createBindings(ASTParser.java:1064)
	at org.eclipse.xtext.common.types.access.JdtTypeProvider.resolveBindings(JdtTypeProvider.java:62)
	at org.eclipse.xtext.common.types.access.JdtTypeProvider.findTypeByName(JdtTypeProvider.java:37)
	at org.eclipse.xtext.common.types.access.DullyTest$DullyJob.run(DullyTest.java:50)








or by this call stack

	at org.eclipse.jdt.internal.core.Buffer.close(Buffer.java:116)
	at org.eclipse.jdt.internal.core.Openable.closeBuffer(Openable.java:96)
	at org.eclipse.jdt.internal.core.Openable.closing(Openable.java:105)
	at org.eclipse.jdt.internal.core.CompilationUnit.closing(CompilationUnit.java:253)
	at org.eclipse.jdt.internal.core.JavaModelManager.removeInfoAndChildren(JavaModelManager.java:4259)
	at org.eclipse.jdt.internal.core.JavaElement.close(JavaElement.java:152)
	at org.eclipse.jdt.internal.core.CompilationUnit.close(CompilationUnit.java:247)
	at org.eclipse.jdt.internal.core.CompilationUnit.becomeWorkingCopy(CompilationUnit.java:94)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.createFileInfo(CompilationUnitDocumentProvider.java:1043)
	at org.eclipse.ui.editors.text.TextFileDocumentProvider.connect(TextFileDocumentProvider.java:481)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.connect(CompilationUnitDocumentProvider.java:1288)
	at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4212)
	at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:260)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1476)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.internalDoSetInput(JavaEditor.java:2575)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.doSetInput(JavaEditor.java:2548)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.doSetInput(CompilationUnitEditor.java:1423)
	at org.eclipse.ui.texteditor.AbstractTextEditor.lambda$1(AbstractTextEditor.java:3179)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:436)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:352)
	at org.eclipse.ui.internal.WorkbenchWindow.lambda$5(WorkbenchWindow.java:2375)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2373)
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3196)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3221)
	at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:353)






or by this call stack

	at org.eclipse.jdt.internal.core.Buffer.close(Buffer.java:116)
	at org.eclipse.jdt.internal.core.Openable.closeBuffer(Openable.java:96)
	at org.eclipse.jdt.internal.core.JavaModelManager.discardPerWorkingCopyInfo(JavaModelManager.java:2023)
	at org.eclipse.jdt.internal.core.DiscardWorkingCopyOperation.executeOperation(DiscardWorkingCopyOperation.java:38)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:736)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
	at org.eclipse.jdt.internal.core.CompilationUnit.discardWorkingCopy(CompilationUnit.java:511)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.disposeFileInfo(CompilationUnitDocumentProvider.java:1271)
	at org.eclipse.ui.editors.text.TextFileDocumentProvider.disconnect(TextFileDocumentProvider.java:655)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.disconnect(CompilationUnitDocumentProvider.java:1347)
	at org.eclipse.ui.texteditor.AbstractTextEditor.disposeDocumentProvider(AbstractTextEditor.java:4511)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.disposeDocumentProvider(AbstractDecoratedTextEditor.java:1458)
	at org.eclipse.ui.texteditor.AbstractTextEditor.dispose(AbstractTextEditor.java:4393)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.dispose(AbstractDecoratedTextEditor.java:390)
	at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.dispose(JavaEditor.java:2687)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.dispose(CompilationUnitEditor.java:1525)
Comment 1 Christian Dietrich CLA 2020-04-23 06:58:23 EDT
Created attachment 282536 [details]
Sample Test Project

All 3 Stacktraces can be seen by running DullyTest in the sample project
Comment 2 Simeon Andreev CLA 2020-05-06 08:11:44 EDT
With the attached test, we have the following concurrent calls:

"main" #1 prio=6 os_prio=0 tid=0x00007ffff0016800 nid=0x3a54 at breakpoint[0x00007ffff7fc8000]
   java.lang.Thread.State: RUNNABLE
        at org.eclipse.jdt.internal.core.Buffer.close(Buffer.java:109)
        at org.eclipse.jdt.internal.core.Openable.closeBuffer(Openable.java:94)
        at org.eclipse.jdt.internal.core.Openable.closing(Openable.java:103)
        at org.eclipse.jdt.internal.core.CompilationUnit.closing(CompilationUnit.java:253)
        at org.eclipse.jdt.internal.core.JavaModelManager.removeInfoAndChildren(JavaModelManager.java:4260)
        - locked <0x0000000081ef4e30> (a org.eclipse.jdt.internal.core.JavaModelManager)
        at org.eclipse.jdt.internal.core.JavaModelManager.discardPerWorkingCopyInfo(JavaModelManager.java:2022)
        at org.eclipse.jdt.internal.core.DiscardWorkingCopyOperation.executeOperation(DiscardWorkingCopyOperation.java:38)
        at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:736)
        at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
        at org.eclipse.jdt.internal.core.CompilationUnit.discardWorkingCopy(CompilationUnit.java:511)
        at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.disposeFileInfo(CompilationUnitDocumentProvider.java:1271)
        at org.eclipse.ui.editors.text.TextFileDocumentProvider.disconnect(TextFileDocumentProvider.java:655)
        at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.disconnect(CompilationUnitDocumentProvider.java:1347)
        at org.eclipse.ui.texteditor.AbstractTextEditor.disposeDocumentProvider(AbstractTextEditor.java:4511)
        at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.disposeDocumentProvider(AbstractDecoratedTextEditor.java:1458)
        at org.eclipse.ui.texteditor.AbstractTextEditor.dispose(AbstractTextEditor.java:4393)
        at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.dispose(AbstractDecoratedTextEditor.java:390)
        at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.dispose(JavaEditor.java:2687)
        at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.dispose(CompilationUnitEditor.java:1525)
        at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.invalidate(CompatibilityPart.java:260)
        at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.destroy(CompatibilityPart.java:417)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
        at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:1002)
        at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:967)
        at org.eclipse.e4.core.internal.di.InjectorImpl.uninject(InjectorImpl.java:200)
        at org.eclipse.e4.core.internal.di.Requestor.uninject(Requestor.java:176)
        at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:89)
        at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:105)
        at org.eclipse.e4.core.internal.contexts.EclipseContext.removeListenersTo(EclipseContext.java:491)
        at org.eclipse.e4.core.contexts.ContextInjectionFactory.uninject(ContextInjectionFactory.java:184)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeRemoveGui(PartRenderingEngine.java:954)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$1(PartRenderingEngine.java:873)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:868)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.removeGui(PartRenderingEngine.java:852)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.subscribeTopicToBeRendered(PartRenderingEngine.java:187)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
        at org.eclipse.e4.core.di.internal.extensions.EventObjectSupplier$DIEventHandler.handleEvent(EventObjectSupplier.java:92)
        at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:205)
        at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:203)
        at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
        at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:132)
        at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:75)
        at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
        at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
        at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:63)
        at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
        at org.eclipse.e4.ui.model.application.ui.impl.UIElementImpl.setToBeRendered(UIElementImpl.java:314)
        at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.hidePart(PartServiceImpl.java:1406)
        at org.eclipse.ui.internal.WorkbenchPage.hidePart(WorkbenchPage.java:1544)
        at org.eclipse.ui.internal.WorkbenchPage.hidePart(WorkbenchPage.java:1496)
        at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1466)
        at org.eclipse.ui.internal.WorkbenchPage.closeAllEditors(WorkbenchPage.java:1343)
        at org.eclipse.xtext.common.types.access.DullyTest.testIt(DullyTest.java:114)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.eclipse.xtext.common.types.access.RepeatedTest$Rule$RepeatedTestStatement.evaluate(RepeatedTest.java:84)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
        at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:117)
        at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.lambda$0(PlatformUITestHarness.java:45)
        at org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness$$Lambda$525/1964626330.run(Unknown Source)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
        - locked <0x00000005919184b8> (a org.eclipse.swt.widgets.RunnableLock)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4928)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4449)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
        at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:658)
        at org.eclipse.ui.internal.Workbench$$Lambda$36/130494156.run(Unknown Source)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
        at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:55)
        at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:46)
        at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:49)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:661)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1476)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1449)

"org.eclipse.jdt.internal.ui.text.JavaReconciler" #94 daemon prio=1 os_prio=0 tid=0x00007ffff2662800 nid=0x3efa runnable [0x00007fff795ab000]
   java.lang.Thread.State: RUNNABLE
        at org.eclipse.jdt.internal.core.Buffer.getCharacters(Buffer.java:141)
        at org.eclipse.jdt.internal.core.CompilationUnit.getContents(CompilationUnit.java:689)
        at org.eclipse.jdt.internal.core.CompilationUnit$1.getContents(CompilationUnit.java:222)
        at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13011)
        at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12983)
        at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:11378)
        at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:849)
        at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:394)
        at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1041)
        at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1114)
        at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:280)
        at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:346)
        at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:193)
        at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:94)
        at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:736)
        at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
        at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1315)
        at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:131)
        at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:113)
        at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:93)
        at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
        at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:90)
        at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.initialReconcile(JavaReconcilingStrategy.java:188)
        at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.initialReconcile(CompositeReconcilingStrategy.java:125)
        at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.initialReconcile(JavaCompositeReconcilingStrategy.java:139)
        at org.eclipse.jface.text.reconciler.MonoReconciler.initialProcess(MonoReconciler.java:98)
        at org.eclipse.jdt.internal.ui.text.JavaReconciler.initialProcess(JavaReconciler.java:423)
        - locked <0x00000005a3202bd8> (a java.lang.Object)                                                                                                                                                         
        at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:177)

Both operate on the same compilation unit object (and so on the same buffer). Run e.g. the test with breakpoints to reproduce.
Comment 3 Eclipse Genie CLA 2020-05-06 09:40:05 EDT
New Gerrit change created: https://git.eclipse.org/r/162565
Comment 4 Christian Dietrich CLA 2020-05-06 12:59:55 EDT
Created attachment 282732 [details]
Updated version of test to avoid memory leak with progress service
Comment 5 Stephan Herrmann CLA 2020-05-14 08:40:34 EDT
Could the following be related?

(In reply to Stephan Herrmann from bug 550180 comment #2)
> Those tests even have a tearDown() that deletes all resources in the project
> except for .* files.
> 
> This implies that buffers are re-used for files that are deleted and created
> again.
> 
> I could observe that deleting the jar file triggers a JavaElementDelta, but
> I could not find any connection from JavaElementDeltas to buffer management.
> 
> Can s.o. please point me to how invalidation of Buffers is supposed to work
> in general?
Comment 6 Simeon Andreev CLA 2020-05-14 09:04:57 EDT
(In reply to Stephan Herrmann from comment #5)
> Could the following be related?
> 
> (In reply to Stephan Herrmann from bug 550180 comment #2)
> > Those tests even have a tearDown() that deletes all resources in the project
> > except for .* files.
> > 
> > This implies that buffers are re-used for files that are deleted and created
> > again.
> > 
> > I could observe that deleting the jar file triggers a JavaElementDelta, but
> > I could not find any connection from JavaElementDeltas to buffer management.
> > 
> > Can s.o. please point me to how invalidation of Buffers is supposed to work
> > in general?

I think here we strictly have a multi-threading problem. Does the test from bug 550180 do things in parallel?
Comment 7 Stephan Herrmann CLA 2020-05-14 13:08:10 EDT
(In reply to Simeon Andreev from comment #6)
> I think here we strictly have a multi-threading problem. Does the test from
> bug 550180 do things in parallel?

The test doesn't actively produce concurrency, but the intermittent (rare) occurrence of the failure still feels like some dependency on timing of background tasks or such.

Anyway, once the patch here is released, I can hammer those tests again to see if the issue still happens.
Comment 8 Simeon Andreev CLA 2020-05-15 03:26:16 EDT
(In reply to Stephan Herrmann from comment #7)
> once the patch here is released, I can hammer those tests again to
> see if the issue still happens.

If the change gets merged (it seems it doesn't help with xtext and our product code), it would help in the following scenario:

1. Thread 1 calls CompilationUnit.getContents().
2. Thread 2 calls CompilationUnit.discardWorkingCopy().

In our case, its possible that Thread 2, in CompilationUnit.discardWorkingCopy(), has closed the buffer of the CU, but the buffer is not yet removed from BufferManager. So CompilationUnit.getContents() throws an exception. This messes up xtext.

With the change, CompilationUnit.getContents() will still provide contents in this case (from the resource, not from the buffer). But other cases are not handled.

From the description of bug  550180, there is a stale buffer? That would mean, CompilationUnit.getContent() uses the buffer although another thread is closing it at the same time (maybe even discarding editor changes)?

I don't think the change would help with a stale buffer, unfortunately.
Comment 10 Eclipse Genie CLA 2022-11-04 00:24:35 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.