Bug 33231 - Deadlock performing CVS decoration while JRE initializers are invoked
Summary: Deadlock performing CVS decoration while JRE initializers are invoked
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 31610 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-02-26 06:23 EST by Philipe Mulet CLA
Modified: 2003-03-11 09:39 EST (History)
1 user (show)

See Also:


Attachments
Deadlock thread dump (11.85 KB, text/plain)
2003-02-26 06:23 EST, Philipe Mulet CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2003-02-26 06:23:09 EST
Build 2.1 RC1

Reopening an old 2.0.2 workspace which was using JRE variable initializer, a 
deadlock occurred when Java perspective was restoring.
Comment 1 Philipe Mulet CLA 2003-02-26 06:23:38 EST
Created attachment 3709 [details]
Deadlock thread dump
Comment 2 Philipe Mulet CLA 2003-02-26 06:27:25 EST
2 locks involved are: workspace lock and JavaModel info lock.
- CVS background decoration is taking workspace lock, and performs some 
resource modification notified to DeltaProcessor (wondering why it would change 
any actual resource the delta processor should care about).
DeltaProcessor is trying to acquire JavaModel info lock.

- Main thread is using populating the JavaModel thus got the info lock, and 
tries to perform some JRE initialization, which in turn is trying to acquire 
the workspace lock.

-> deadlocked



Comment 3 Philipe Mulet CLA 2003-02-26 06:28:17 EST
1. why is deltaprocessor populating the model in reaction to CVS changes ?
2. shouldn't we free the model lock while running JRE initializer ?
Comment 4 John Arthorne CLA 2003-02-26 11:40:50 EST
VCM plans to fix this particular instance... they believe they should never be
modifying the workspace from inside the decorator thread.  However, another
plugin could easily install a decorator that modifies resources, leaving us open
to the same problem.  I don't think this problem can be solved by checking if
the delta contains only sync info changes (seeing as it was a bug in CVS code
that generated this delta, it's not an expected case).
Comment 5 Philipe Mulet CLA 2003-02-27 10:12:38 EST
The delta check is just a workaround to prevent an obvious scenario to cause 
grief. 

Our code clearly is subject to such deadlocks, if someone
performs any multi-threaded action before we have resolved all classpaths.
CVS decoration is an example, but I suspect other may find this. 

Our locked area should never contain any client code, however our lazy
initialization story can cause this to occur. 

I suspect working copy reconciling is another instance where we may be 
notifying clients (with discovered errors) while we are inside the JavaModel 
lock (need to double check some more).
Comment 6 Philipe Mulet CLA 2003-02-28 05:56:08 EST
We have a regression test for such offending scenario (not released in regular 
test suites since could be causing major hang).
-> ThreadSafetyTests#testDeadlock01()
Comment 7 Philipe Mulet CLA 2003-02-28 07:14:59 EST
Also see bug 31530 for similar deadlock due to the JavaModel lock being 
surfaced to clients (in this scenario, the actual locking is achieved by 
accessing perProjectInfo which need JavaModel lock too).

Per project infos do not need the JavaModel(Manager) lock, they simply need to 
be synchronized with each other. Should sync on a different object (e.g. per 
project info table).
Comment 8 Philipe Mulet CLA 2003-03-01 05:08:59 EST
PerProjectInfo are now synchronized on their table.
Made similar changes onto zipfile cache.

Ensure classpath is resolved before opening an element (#getElementInfo), 
avoiding initializer client code invocation while our lock is taken.

Moved working copy problem detection (while reconciliation) outside of the lock 
as well.

There shouldn't be any occurrence of 3rd party code running while we are inside 
the lock (entered bug 33530 to revisit post 2.1 so as to make the element info 
creation more optimistic).
Comment 9 Philipe Mulet CLA 2003-03-03 05:08:17 EST
Fixed.
Comment 10 Philipe Mulet CLA 2003-03-05 06:21:03 EST
*** Bug 31610 has been marked as a duplicate of this bug. ***
Comment 11 David Audel CLA 2003-03-11 09:39:03 EST
Verified.