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

Bug 305566

Summary: ConvertJob causing potential deadlock with ModelManagerImpl
Product: z_Archived Reporter: Cameron Bateman <cameron.bateman>
Component: Webtools.WST.JavascriptAssignee: Project Inbox <jsdt.javascript-inbox>
Status: CLOSED DUPLICATE QA Contact: Nitin Dahyabhai <thatnitind>
Severity: critical    
Priority: P3 CC: gerry.kessler, raghunathan.srinivasan
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Cameron Bateman CLA 2010-03-11 13:57:13 EST
Seen in 3.2M6 codeline.

The trace below shows a deadlock between an attempt to acquire a structured model on the main thread and Worker-0.  In main sharedObject lock is being held and the Java code called indirectly by JDT is attempting to a check-in.  Meanwhile, ConvertJob has triggered the broadcastChanges operation at the end of a workspace runnable.  The framework holds the global Orderlock while doing this so Main blocks on this while holding the sharedObject.  Worker-0 then blocks on the sharedObject lock while blocking Main.

I think the solution here is to move the code that does the resourceChanged handling in JSPTranslatorPersiter to a new thread or job.  This is generally considered best practice to handle resource change events when the handler intends to touch workspace objects.



org.eclipse.equinox.launcher.Main at localhost:2581 (Suspended)	
	Thread [Main Thread] (Suspended)	
		owns: ModelManagerImpl$SharedObject  (id=251)	
			waited by: Thread [Worker-0] (Suspended)	
		owns: RunnableLock  (id=250)	
		waiting for: Semaphore  (id=146)	
		Object.wait(long) line: not available [native method]	
		Semaphore.acquire(long) line: 38	
		OrderedLock.doAcquire(Semaphore, long) line: 168	
		OrderedLock.acquire(long) line: 105	
		OrderedLock.acquire() line: 82	
		WorkManager.checkIn(ISchedulingRule, IProgressMonitor) line: 118	
		Workspace.prepareOperation(ISchedulingRule, IProgressMonitor) line: 1914	
		Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 1970	
		JavaModelManager.initializeAllContainers(IJavaProject, IPath) line: 2641	
		JavaModelManager.getClasspathContainer(IPath, IJavaProject) line: 1837	
		JavaCore.getClasspathContainer(IPath, IJavaProject) line: 2699	
		JavaProject.resolveClasspath(IClasspathEntry[], IClasspathEntry[], boolean, boolean) line: 2639	
		JavaProject.resolveClasspath(JavaModelManager$PerProjectInfo, boolean, boolean) line: 2777	
		JavaProject.getResolvedClasspath(boolean) line: 1946	
		ProjectDescription.ensureUpTodate() line: 994	
		ProjectDescription.resolve(String, String) line: 1743	
		TaglibIndex.internalResolve(String, String, boolean) line: 938	
		TaglibIndex.resolve(String, String, boolean) line: 578	
		TLDCMDocumentManager.getCacheKey(String) line: 686	
		TLDCMDocumentManager.getCMDocument(String) line: 701	
		TLDCMDocumentManager$DirectiveStructuredDocumentRegionHandler.enableTags(String, String, IStructuredDocumentRegion) line: 121	
		TLDCMDocumentManager$DirectiveStructuredDocumentRegionHandler.enableTaglibFromURI(String, String, IStructuredDocumentRegion) line: 111	
		TLDCMDocumentManager$DirectiveStructuredDocumentRegionHandler.processTaglib(ITextRegionCollection, IStructuredDocumentRegion, XMLSourceParser) line: 404	
		TLDCMDocumentManager$DirectiveStructuredDocumentRegionHandler.processRegionCollection(ITextRegionCollection, IStructuredDocumentRegion, XMLSourceParser) line: 175	
		TLDCMDocumentManager$DirectiveStructuredDocumentRegionHandler.nodeParsed(IStructuredDocumentRegion) line: 191	
		JSPSourceParser(XMLSourceParser).fireNodeParsed(IStructuredDocumentRegion) line: 135	
		JSPSourceParser.parseNodes() line: 296	
		JSPSourceParser(XMLSourceParser).getDocumentRegions() line: 173	
		JSPReParser(StructuredDocumentReParser)._core_reparse_text(int, int) line: 309	
		JSPReParser(StructuredDocumentReParser).core_reparse(int, int, CoreNodeList, boolean) line: 709	
		JSPReParser.reparse(IStructuredDocumentRegion, IStructuredDocumentRegion) line: 143	
		JSPReParser(StructuredDocumentReParser).reparse() line: 1287	
		JobSafeStructuredDocument(BasicStructuredDocument).updateModel(Object, int, int, String) line: 2709	
		JobSafeStructuredDocument(BasicStructuredDocument).internalReplaceText(Object, int, int, String, long, boolean) line: 1923	
		JobSafeStructuredDocument(BasicStructuredDocument).replaceText(Object, int, int, String, long, boolean) line: 2419	
		JobSafeStructuredDocument(BasicStructuredDocument).set(String, long) line: 2931	
		ResourceTextFileBuffer.setDocumentContent(IDocument, IFile, String) line: 575	
		ResourceTextFileBuffer.initializeFileBufferContent(IProgressMonitor) line: 286	
		ResourceTextFileBuffer(ResourceFileBuffer).create(IPath, IProgressMonitor) line: 245	
		ResourceTextFileBufferManager(TextFileBufferManager).connect(IPath, LocationKind, IProgressMonitor) line: 113	
		FileBufferModelManager.getModel(IFile) line: 654	
		ModelManagerImpl._doCommonGetModel(IFile, String, ModelManagerImpl$SharedObject, ModelManagerImpl$ReadEditType) line: 504	
		ModelManagerImpl._commonGetModel(IFile, String, IModelHandler, URIResolver, ModelManagerImpl$ReadEditType, String, String) line: 471	
		ModelManagerImpl._commonGetModel(IFile, ModelManagerImpl$ReadEditType, String, String) line: 444	
		ModelManagerImpl.getModelForRead(IFile) line: 1373	
		TestJSPSemanticsValidator_AttributeValues.testSanity() line: 73	
		NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
		NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
		DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
		Method.invoke(Object, Object...) line: 597	
		TestJSPSemanticsValidator_AttributeValues(TestCase).runTest() line: 168	
		TestJSPSemanticsValidator_AttributeValues(TestCase).runBare() line: 134	
		TestResult$1.protect() line: 110	
		TestResult.runProtected(Test, Protectable) line: 128	
		TestResult.run(TestCase) line: 113	
		TestJSPSemanticsValidator_AttributeValues(TestCase).run(TestResult) line: 124	
		TestSuite.runTest(Test, TestResult) line: 232	
		TestSuite.run(TestResult) line: 227	
		TestSuite.runTest(Test, TestResult) line: 232	
		TestSuite.run(TestResult) line: 227	
		SuiteMethod(JUnit38ClassRunner).run(RunNotifier) line: 83	
		JUnit4TestClassReference(JUnit4TestReference).run(TestExecution) line: 49	
		TestExecution.run(ITestReference[]) line: 38	
		RemotePluginTestRunner(RemoteTestRunner).runTests(String[], String, TestExecution) line: 467	
		RemotePluginTestRunner(RemoteTestRunner).runTests(TestExecution) line: 683	
		RemotePluginTestRunner(RemoteTestRunner).run() line: 390	
		RemotePluginTestRunner.main(String[]) line: 61	
		UITestApplication$1.run() line: 116	
		RunnableLock.run() line: 35	
		UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 134	
		Display.runAsyncMessages(boolean) line: 4012	
		Display.readAndDispatch() line: 3631	
		Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2408	
		Workbench.runUI() line: 2372	
		Workbench.access$4(Workbench) line: 2221	
		Workbench$5.run() line: 501	
		Realm.runWithDefault(Realm, Runnable) line: 332	
		Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 494	
		PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
		IDEApplication.start(IApplicationContext) line: 115	
		UITestApplication.start(IApplicationContext) line: 47	
		EclipseAppHandle.run(Object) line: 196	
		EclipseAppLauncher.runApplication(Object) line: 110	
		EclipseAppLauncher.start(Object) line: 79	
		EclipseStarter.run(Object) line: 369	
		EclipseStarter.run(String[], Runnable) line: 179	
		NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
		NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
		DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
		Method.invoke(Object, Object...) line: 597	
		Main.invokeFramework(String[], URL[]) line: 619	
		Main.basicRun(String[]) line: 574	
		Main.run(String[]) line: 1406	
		Main.main(String[]) line: 1382	
	Daemon System Thread [(Signal Handler)] (Suspended)	
	Daemon System Thread [(GC Main Thread)] (Suspended)	
	Daemon System Thread [(Code Generation Thread 1)] (Suspended)	
	Daemon System Thread [(Code Optimization Thread 1)] (Suspended)	
	Daemon System Thread [(VM Periodic Task)] (Suspended)	
	Daemon System Thread [(Attach Listener)] (Suspended)	
	Daemon System Thread [Finalizer] (Suspended)	
	Daemon System Thread [Reference Handler] (Suspended)	
	Daemon System Thread [(Sensor Event Thread)] (Suspended)	
	Daemon System Thread [RMI TCP Accept-0] (Suspended)	
	Daemon Thread [Framework Event Dispatcher] (Suspended)	
	Daemon Thread [Start Level Event Dispatcher] (Suspended)	
	Daemon Thread [Bundle File Closer] (Suspended)	
	Thread [Worker-JM] (Suspended)	
	Daemon Thread [[Timer] - Main Queue Handler] (Suspended)	
	Thread [Worker-0] (Suspended)	
		waiting for: ModelManagerImpl$SharedObject  (id=251)	
			owned by: Thread [Main Thread] (Suspended)	
				waiting for: Semaphore  (id=146)	
		<unknown receiving type>(ModelManagerImpl$SharedObject).waitForLoadAttempt() line: 128	
		ModelManagerImpl._commonGetModel(IFile, String, IModelHandler, URIResolver, ModelManagerImpl$ReadEditType, String, String) line: 461	
		ModelManagerImpl._commonGetModel(IFile, ModelManagerImpl$ReadEditType, String, String) line: 444	
		ModelManagerImpl.getModelForRead(IFile) line: 1373	
		JSPTranslatorPersister$JSPResourceVisitor.getJSPTranslator(IPath) line: 309	
		JSPTranslatorPersister$JSPResourceVisitor.visit(IResourceDelta) line: 246	
		ResourceDelta.accept(IResourceDeltaVisitor, int) line: 68	
		ResourceDelta.accept(IResourceDeltaVisitor, int) line: 79	
		ResourceDelta.accept(IResourceDeltaVisitor, int) line: 79	
		ResourceDelta.accept(IResourceDeltaVisitor, int) line: 79	
		ResourceDelta.accept(IResourceDeltaVisitor, boolean) line: 55	
		JSPTranslatorPersister.resourceChanged(IResourceChangeEvent) line: 120	
		NotificationManager$2.run() line: 291	
		SafeRunner.run(ISafeRunnable) line: 42	
		NotificationManager.notify(ResourceChangeListenerList$ListenerEntry[], IResourceChangeEvent, boolean) line: 285	
		NotificationManager.broadcastChanges(ElementTree, ResourceChangeEvent, boolean) line: 149	
		Workspace.broadcastPostChange() line: 327	
		Workspace.endOperation(ISchedulingRule, boolean, IProgressMonitor) line: 1181	
		ConvertJob(InternalWorkspaceJob).run(IProgressMonitor) line: 45	
		Worker.run() line: 54	
	Daemon Thread [Java indexing] (Suspended)	
	Thread [Worker-1] (Suspended)	
	Thread [WorkbenchTestable] (Suspended)	
	Thread [Worker-3] (Suspended)	
	Thread [Worker-2] (Suspended)	
	Thread [Worker-4] (Suspended)	
	Thread [Worker-5] (Suspended)	
	Thread [Worker-6] (Suspended)	
		waiting for: Semaphore  (id=174)	
		Object.wait(long) line: not available [native method]	
		Semaphore.acquire(long) line: 38	
		OrderedLock.doAcquire(Semaphore, long) line: 168	
		OrderedLock.acquire(long) line: 105	
		OrderedLock.acquire() line: 82	
		WorkManager.checkIn(ISchedulingRule, IProgressMonitor) line: 118	
		Workspace.prepareOperation(ISchedulingRule, IProgressMonitor) line: 1914	
		Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 1970	
		SetContainerOperation(JavaModelOperation).runOperation(IProgressMonitor) line: 793	
		JavaCore.setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor) line: 4833	
		WebAppLibrariesContainer.install() line: 73	
		WebAppLibrariesContainer.refresh() line: 84	
		J2EEComponentClasspathUpdater$ModuleUpdateJob.processModules(Object[]) line: 294	
		J2EEComponentClasspathUpdater$ModuleUpdateJob.access$4(J2EEComponentClasspathUpdater$ModuleUpdateJob, Object[]) line: 286	
		J2EEComponentClasspathUpdater$ModuleUpdateJob$1.run() line: 327	
		SafeRunner.run(ISafeRunnable) line: 42	
		J2EEComponentClasspathUpdater$ModuleUpdateJob.run(IProgressMonitor) line: 312	
		Worker.run() line: 54	
	Thread [ReaderThread] (Suspended)	
	Daemon Thread [JavaScript indexing] (Suspended)	
	Daemon Thread [[ThreadPool Manager] - Idle Thread] (Suspended)
Comment 1 Nitin Dahyabhai CLA 2010-03-14 05:50:15 EDT
Any WorkspaceJob could cause this.

*** This bug has been marked as a duplicate of bug 305339 ***