Bug 205533 - Deadlock in LazyLookupProviders
Deadlock in LazyLookupProviders
Status: RESOLVED FIXED
Product: projects
Classification: Unclassified
Component: Generic Infrastructure
7.2
PC Linux
: P3 (vote)
: 7.2
Assigned To: Jesse Glick
issues@projects
: THREAD
: 205647 (view as bug list)
Depends on: 209815
Blocks: 205268
  Show dependency treegraph
 
Reported: 2011-11-24 17:01 UTC by Ondrej Vrabec
Modified: 2012-04-03 16:29 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
thread dump (8.32 KB, text/plain)
2011-11-24 17:01 UTC, Ondrej Vrabec
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Vrabec 2011-11-24 17:01:35 UTC
Created attachment 113512 [details]
thread dump

IDE locked while i tried to open the projects view after i switched from commandline back to the IDE

Product Version: NetBeans IDE Dev (Build 20111122-9a8edc0fe2de)
Java: 1.6.0_29; Java HotSpot(TM) 64-Bit Server VM 20.4-b02
System: Linux version 2.6.37.6-0.9-desktop running on amd64; UTF-8; en_US (nb)
User directory: /home/ondra/.netbeans/dev
Cache directory: /home/ondra/.netbeans/dev/var/cache
Comment 1 Jesse Glick 2011-11-29 12:38:39 UTC
I got it too.

"LocalHistory.ParallelTasks":
  waiting to lock monitor 0x0a62b224 (object 0x9d5fa718, a org.netbeans.modules.projectapi.LazyLookupProviders$1$1),
  which is held by "org.netbeans.modules.project.ui.ProjectsRootNode$ProjectChildren"
"org.netbeans.modules.project.ui.ProjectsRootNode$ProjectChildren":
  waiting to lock monitor 0x09b978c8 (object 0x9d5fa700, a org.netbeans.modules.projectapi.LazyLookupProviders$1$1),
  which is held by "LocalHistory.ParallelTasks"

	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:80)
	- waiting to lock <0x9d5fa718> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:206)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:214)
	at org.openide.util.lookup.ExcludingLookup.lookup(ExcludingLookup.java:108)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:214)
	at org.netbeans.modules.maven.j2ee.J2eeMavenSourcesImpl.<init>(J2eeMavenSourcesImpl.java:89)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.netbeans.modules.projectapi.LazyLookupProviders.loadPSPInstance(LazyLookupProviders.java:110)
	at org.netbeans.modules.projectapi.LazyLookupProviders.access$000(LazyLookupProviders.java:67)
	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:83)
	- locked <0x9d5fa700> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)

	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:80)
	- waiting to lock <0x9d5fa700> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:206)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:214)
	at org.openide.util.lookup.ExcludingLookup.lookup(ExcludingLookup.java:108)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:214)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:214)
	at org.netbeans.modules.projectapi.LazyLookupProviders.valuesFor(LazyLookupProviders.java:135)
	at org.netbeans.modules.projectapi.LazyLookupProviders.loadPSPInstance(LazyLookupProviders.java:108)
	at org.netbeans.modules.projectapi.LazyLookupProviders.access$000(LazyLookupProviders.java:67)
	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:83)
	- locked <0x9d5fa718> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)
Comment 2 Jesse Glick 2011-11-29 12:54:14 UTC
Introduced by the fix for bug #205268. Tricky: we do not want to deadlock, but we also do not want the same service interface to be instantiated by two different threads. Probably OK if this happens so long as only one such instance actually winds up in the lookup.

The deeper problem is that in the Maven project lookup, some service impls call project.getLookup() in the constructor to find other services; this ought to be forbidden, and maybe the infrastructure should enforce this with an assertion. Can accept Lookup baseLookup as a ctor param (only certain interfaces available, like NbMavenProject); but better still to delay checking project lookup for other things until service methods are actually called.
Comment 3 Jesse Glick 2011-11-29 13:02:54 UTC
core-main #789d7cef2778
Comment 4 Jesse Glick 2011-11-29 13:53:41 UTC
Still another deadlock possible:

Found one Java-level deadlock:
=============================
"Parsing & Indexing Loop (20111129-9efe76f9f5d3)":
  waiting to lock monitor 0x094550b8 (object 0x9ceec258, a org.netbeans.modules.projectapi.LazyLookupProviders$1$1),
  which is held by "ErrorAnnotator worker"
"ErrorAnnotator worker":
  waiting to lock monitor 0x091a7264 (object 0x9ce58bf8, a java.util.ArrayList),
  which is held by "Parsing & Indexing Loop (20111129-9efe76f9f5d3)"

Java stack information for the threads listed above:
===================================================
"Parsing & Indexing Loop (20111129-9efe76f9f5d3)":
	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:87)
	- waiting to lock <0x9ceec258> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:672)
	at org.openide.util.lookup.ProxyLookup$R.beforeLookup(ProxyLookup.java:691)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:680)
	at org.openide.util.lookup.ProxyLookup$R.beforeLookup(ProxyLookup.java:691)
	at org.openide.util.lookup.ExcludingLookup$R.beforeLookup(ExcludingLookup.java:294)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:680)
	at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:526)
	at org.openide.util.lookup.ProxyLookup$R.allItems(ProxyLookup.java:517)
	at org.openide.util.lookup.ProxyLookup$R.collectFires(ProxyLookup.java:628)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:168)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:124)
	at org.netbeans.spi.project.support.DelegatingLookupImpl.doDelegate(DelegatingLookupImpl.java:176)
	- locked <0x9ce58bf8> (a java.util.ArrayList)
	at org.netbeans.spi.project.support.DelegatingLookupImpl.stateChanged(DelegatingLookupImpl.java:112)
	at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:329)
	at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:133)
	at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:119)
	at org.netbeans.modules.projectapi.LazyLookupProviders$2.probing(LazyLookupProviders.java:188)
	at org.netbeans.spi.project.support.DelegatingLookupImpl.beforeLookup(DelegatingLookupImpl.java:106)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:206)
	at org.netbeans.modules.maven.queries.MavenForBinaryQueryImpl$BinResult.preferSources(MavenForBinaryQueryImpl.java:339)
	at org.netbeans.api.java.queries.SourceForBinaryQuery$Result2.preferSources(SourceForBinaryQuery.java:228)
	at org.netbeans.modules.parsing.impl.indexing.PathRegistry.createResources(PathRegistry.java:626)
	at org.netbeans.modules.parsing.impl.indexing.PathRegistry.getSources(PathRegistry.java:234)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$RootsWork.getDone(RepositoryUpdater.java:3455)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Work.doTheWork(RepositoryUpdater.java:2505)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task._run(RepositoryUpdater.java:4518)
	at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater$Task.run(RepositoryUpdater.java:4455)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:618)
	at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:728)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
"ErrorAnnotator worker":
	at org.netbeans.spi.project.support.DelegatingLookupImpl.doDelegate(DelegatingLookupImpl.java:117)
	- waiting to lock <0x9ce58bf8> (a java.util.ArrayList)
	at org.netbeans.spi.project.support.DelegatingLookupImpl.resultChanged(DelegatingLookupImpl.java:101)
	at org.openide.util.lookup.ProxyLookup$1Notify.run(ProxyLookup.java:179)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:188)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:124)
	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:103)
	- locked <0x9ceec258> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:672)
	at org.openide.util.lookup.ProxyLookup$R.beforeLookup(ProxyLookup.java:691)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:680)
	at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:526)
	at org.openide.util.lookup.ProxyLookup$R.allInstances(ProxyLookup.java:497)
	at org.openide.util.Lookup.lookupAll(Lookup.java:263)
	at org.netbeans.modules.maven.queries.ForeignClassBundlerMerger$1.preferSources(ForeignClassBundlerMerger.java:55)
	at org.netbeans.modules.maven.queries.MavenForBinaryQueryImpl$BinResult.preferSources(MavenForBinaryQueryImpl.java:339)
	at org.netbeans.api.java.queries.SourceForBinaryQuery$Result2.preferSources(SourceForBinaryQuery.java:228)
	at org.netbeans.modules.parsing.impl.indexing.PathRegistry.createResources(PathRegistry.java:626)
	at org.netbeans.modules.parsing.impl.indexing.PathRegistry.getSources(PathRegistry.java:234)
	at org.netbeans.modules.parsing.impl.indexing.errors.Utilities.findIndexedRootsUnderDirectory(Utilities.java:85)
	at org.netbeans.modules.parsing.impl.indexing.errors.ErrorAnnotator$1.run(ErrorAnnotator.java:316)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1411)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1991)
Comment 5 Jesse Glick 2011-11-29 14:06:10 UTC
core-main #a29c95eb9e24
Comment 6 Jesse Glick 2011-11-29 15:53:01 UTC
(In reply to comment #2)
> The deeper problem is that in the Maven project lookup, some service impls call
> project.getLookup() in the constructor to find other services; this ought to be
> forbidden, and maybe the infrastructure should enforce this with an assertion.

Should be addressed in core-main #4a0289b39cb6.
Comment 7 Jesse Glick 2011-11-29 20:45:59 UTC
Still not enough:

	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:90)
	- waiting to lock <0xb3b10678> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:672)
	at org.openide.util.lookup.ProxyLookup$R.beforeLookup(ProxyLookup.java:691)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:680)
	at org.openide.util.lookup.ProxyLookup$R.beforeLookup(ProxyLookup.java:691)
	at org.openide.util.lookup.ExcludingLookup$R.beforeLookup(ExcludingLookup.java:294)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:680)
	at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:526)
	at org.openide.util.lookup.ProxyLookup$R.allInstances(ProxyLookup.java:497)
	at org.openide.util.lookup.ProxyLookup$R.collectFires(ProxyLookup.java:634)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:168)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:124)
	at org.netbeans.spi.project.support.DelegatingLookupImpl.doDelegate(DelegatingLookupImpl.java:178)
	at org.netbeans.spi.project.support.DelegatingLookupImpl.resultChanged(DelegatingLookupImpl.java:101)
	at org.openide.util.lookup.ProxyLookup$1Notify.run(ProxyLookup.java:179)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:188)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:124)
	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:106)
	- locked <0xb3bb7918> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)

	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:90)
	- waiting to lock <0xb3bb7918> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:672)
	at org.openide.util.lookup.ProxyLookup$R.beforeLookup(ProxyLookup.java:691)
	at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:680)
	at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:526)
	at org.openide.util.lookup.ProxyLookup$R.allItems(ProxyLookup.java:517)
	at org.openide.util.lookup.ProxyLookup$R.collectFires(ProxyLookup.java:639)
	at org.openide.util.lookup.ProxyLookup$WeakResult.collectFires(ProxyLookup.java:756)
	at org.openide.util.lookup.AbstractLookup.notifyListeners(AbstractLookup.java:562)
	at org.openide.util.lookup.ProxyLookup$R.collectFires(ProxyLookup.java:662)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:168)
	at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:124)
	at org.netbeans.modules.projectapi.LazyLookupProviders$1$1.beforeLookup(LazyLookupProviders.java:106)
	- locked <0xb3b10678> (a org.netbeans.modules.projectapi.LazyLookupProviders$1$1)
Comment 8 Jesse Glick 2011-11-29 20:58:36 UTC
Does not look like I can assure that only one instance of the service will ever appear in the project lookup without enough synchronization that some deadlocks will occur. The race condition seems preferable.
Comment 9 Jesse Glick 2011-11-29 21:05:20 UTC
core-main #42b57f76c282
Comment 10 Quality Engineering 2011-12-01 12:09:25 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/789d7cef2778
User: Jesse Glick <jglick@netbeans.org>
Log: #205533: Deadlock in LazyLookupProviders
Comment 11 Jesse Glick 2011-12-09 16:02:59 UTC
*** Bug 205647 has been marked as a duplicate of this bug. ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo