eclipse-pde / eclipse.pde

Eclipse Public License 2.0
28 stars 74 forks source link

Deadlock in PluginModelManager #907

Closed basilevs closed 11 months ago

basilevs commented 11 months ago

Environment: Eclipse SDK Version: 2023-12 (4.30) Build id: I20231027-1800 OS: Mac OS X, v.12.7, aarch64 / cocoa Java vendor: Oracle Corporation Java runtime version: 17.0.4.1+1-LTS-2 Java version: 17.0.4.1

To reproduce

Deadlock traces:

"Worker-191: Load Target Platform" #5164 prio=5 os_prio=31 cpu=3489.37ms elapsed=2671.59s tid=0x000000032e774600 nid=0x7c393 waiting on condition  [0x000000032361a000]
   java.lang.Thread.State: TIMED_WAITING (parking)
    at jdk.internal.misc.Unsafe.park(java.base@17.0.4.1/Native Method)
    - parking to wait for  <0x00000007f06257a0> (a java.util.concurrent.Semaphore$NonfairSync)
    at java.util.concurrent.locks.LockSupport.parkNanos(java.base@17.0.4.1/LockSupport.java:252)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(java.base@17.0.4.1/AbstractQueuedSynchronizer.java:717)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(java.base@17.0.4.1/AbstractQueuedSynchronizer.java:1074)
    at java.util.concurrent.Semaphore.tryAcquire(java.base@17.0.4.1/Semaphore.java:415)
    at org.eclipse.ui.internal.PendingSyncExec.acquire(PendingSyncExec.java:39)
    at org.eclipse.ui.internal.PendingSyncExec.waitUntilExecuted(PendingSyncExec.java:88)
    at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:142)
    at org.eclipse.swt.widgets.Display.syncExec(Display.java:5250)
    at org.eclipse.pde.internal.ui.editor.product.ProductInfoSection.stateChanged(ProductInfoSection.java:430)
    at org.eclipse.pde.internal.core.PluginModelManager.fireStateChanged(PluginModelManager.java:442)
    at org.eclipse.pde.internal.core.PluginModelManager.initializeTable(PluginModelManager.java:659)
    at org.eclipse.pde.internal.core.PluginModelManager.targetReloaded(PluginModelManager.java:542)
    - locked <0x00000007b75e82a8> (a java.lang.Object)
    at org.eclipse.pde.core.target.LoadTargetDefinitionJob.resetPlatform(LoadTargetDefinitionJob.java:184)
    at org.eclipse.pde.core.target.LoadTargetDefinitionJob.runInWorkspace(LoadTargetDefinitionJob.java:145)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

"main" #1 prio=6 os_prio=31 cpu=825311.29ms elapsed=13309.28s tid=0x0000000158815600 nid=0x103 waiting for monitor entry  [0x000000016ce31000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at org.eclipse.pde.internal.core.PluginModelManager.findEntry(PluginModelManager.java:1027)
    - waiting to lock <0x00000007b75e82a8> (a java.lang.Object)
    at org.eclipse.pde.internal.core.PluginModelManager.findModel(PluginModelManager.java:1085)
    at org.eclipse.pde.core.plugin.PluginRegistry.findModel(PluginRegistry.java:126)
    at org.eclipse.pde.internal.core.annotations.OSGiAnnotationsClasspathContributor.getInitialEntries(OSGiAnnotationsClasspathContributor.java:50)
    at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.computePluginEntriesByModel(RequiredPluginsClasspathContainer.java:172)
    at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.getClasspathEntries(RequiredPluginsClasspathContainer.java:123)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:3278)
    at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:3436)
    at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:2522)
    at org.eclipse.jdt.internal.core.JavaModelManager.determineIfOnClasspath(JavaModelManager.java:1157)
    at org.eclipse.jdt.internal.core.JavaModelManager.create(JavaModelManager.java:1051)
    at org.eclipse.jdt.internal.core.JavaModelManager.create(JavaModelManager.java:981)
    at org.eclipse.jdt.core.JavaCore.create(JavaCore.java:3708)
    at org.eclipse.jdt.ui.StandardJavaElementContentProvider.internalGetParent(StandardJavaElementContentProvider.java:527)
    at org.eclipse.jdt.ui.StandardJavaElementContentProvider.getParent(StandardJavaElementContentProvider.java:248)
    at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorBreadcrumb$JavaEditorBreadcrumbContentProvider.getParent(JavaEditorBreadcrumb.java:353)
    at org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.BreadcrumbViewer.buildItemChain(BreadcrumbViewer.java:571)
    at org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.BreadcrumbViewer.buildItemChain(BreadcrumbViewer.java:573)
    at org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.BreadcrumbViewer.buildItemChain(BreadcrumbViewer.java:573)
    at org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.BreadcrumbViewer.inputChanged(BreadcrumbViewer.java:275)
    at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:282)
    at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1641)
    at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorBreadcrumb$ElementChangeListener.lambda$0(JavaEditorBreadcrumb.java:481)
    at org.eclipse.jdt.internal.ui.javaeditor.JavaEditorBreadcrumb$ElementChangeListener$$Lambda$3082/0x00000008021d5070.run(Unknown Source)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
    - locked <0x00000007f71bf140> (a org.eclipse.swt.widgets.RunnableLock)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4368)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3991)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:645)
    at org.eclipse.ui.internal.Workbench$$Lambda$233/0x0000000800e0e540.run(Unknown Source)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:342)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:552)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@17.0.4.1/Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@17.0.4.1/NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@17.0.4.1/DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(java.base@17.0.4.1/Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:651)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:588)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1459)
iloveeclipse commented 11 months ago

No IDE at hand right now, but I assume replacing sync with async exec below would fix that without functional problems for the editoe

org.eclipse.swt.widgets.Display.syncExec(Display.java:5250)

vogella commented 11 months ago

@basilevs can you test https://github.com/eclipse-pde/eclipse.pde/pull/921?

basilevs commented 11 months ago

@basilevs can you test #921?

Sorry, I can't reproduce the original problem - there seems to be some kind of timing involved.

vogella commented 11 months ago

Still, please try the patch and see if you see ANY issues with it. If not, I plan to merge early next release.

basilevs commented 11 months ago

try the patch

OK, how do I install it with Oomph? Or failing that, how do I get the prebuilt package? I can't find any relevant artifacts for PR builds.

merks commented 11 months ago

There's this if that's what you're asking:

https://github.com/eclipse-pde/.github/blob/main/CONTRIBUTING.md#create-an-eclipse-development-environment

basilevs commented 11 months ago

There's this if that's what you're asking: https://github.com/eclipse-pde/.github/blob/main/CONTRIBUTING.md#create-an-eclipse-development-environment

That's development environment. How would I test Oomph target definition in a patch with it? I guess I can start a PDE instance from sources, but how to configure it with Oomph? Or how to populate it with all the stuff Oomph does?

merks commented 11 months ago

Sorry, yes, the PR builds don't produce an update site that you can test...

basilevs commented 11 months ago

I've tried to open "Shared" target definition in a PDE started from sources and it shows empty repository tree. Looks like default launch configuration is missing some relevant plugins.

iloveeclipse commented 11 months ago

Should be easy to reproduce.

basilevs commented 11 months ago

Reproduced on master.

basilevs commented 11 months ago

@vogella I confirm the fix helps when testing with debugger as per steps by @iloveeclipse

iloveeclipse commented 11 months ago

@basilevs : thanks for trying out. I simply have no time to do that. @vogella : I've commented on PR, I believe if we fix one occurrence of bad pattern, we should also fix another one.

vogella commented 11 months ago

@basilevs thanks for verifying @iloveeclipse thanks for the review -> updated with your suggestion