Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335910 - SynchronizableDocument causes deadlock by firing events inside of a lock
Summary: SynchronizableDocument causes deadlock by firing events inside of a lock
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.6.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Compare-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-31 17:00 EST by Kevan Holdaway CLA
Modified: 2021-10-31 18:56 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevan Holdaway CLA 2011-01-31 17:00:13 EST
Build Identifier: M20110112-0800

Our product add their own positions to the documents of open editors.  We use the standard eclipse org.eclipse.jface.text.IDocument.addPosition(String, Position) and org.eclipse.jface.text.IDocument.removePosition(String, Position) methods.

SynchronizableDocument fires events inside of the same lock it uses for addPosition/removePosition.  This can cause a deadlock.  Firing events in a lock is poor design as it puts an expectation on clients who handle the code.

Here is a sample stack trace found in a deadlock we experienced:
org/eclipse/jface/text/AbstractDocument.fireRewriteSessionChanged(Bytecode PC:50)
org/eclipse/jface/text/AbstractDocument.stopRewriteSession(Bytecode PC:87)
org/eclipse/core/internal/filebuffers/SynchronizableDocument.stopRewriteSession(Bytecode PC:21)

Note the code for stopRewriteSession:
	public void stopRewriteSession(DocumentRewriteSession session) {
		Object lockObject= getLockObject();
		if (lockObject == null) {
			super.stopRewriteSession(session);
			return;
		}
		synchronized (lockObject) {
			super.stopRewriteSession(session);
		}
	}

It makes the call to super.stopRewriteSession inside of the synchronized block.  This caused our product a deadlock.  

Reproducible: Sometimes
Comment 1 Lars Vogel CLA 2019-09-24 13:58:02 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.
Comment 2 Eclipse Genie CLA 2021-10-31 18:56:27 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.