This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 29581 - Deadlock in DOP.Validator
Summary: Deadlock in DOP.Validator
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Data Systems (show other bugs)
Version: 3.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: David Strupl
URL:
Keywords: THREAD
: 25032 25605 28648 29809 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-12-16 19:40 UTC by Jesse Glick
Modified: 2008-12-23 11:49 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Thread dump (8.75 KB, text/plain)
2002-12-16 19:41 UTC, Jesse Glick
Details
Proposed patch (2.96 KB, text/plain)
2003-01-08 16:02 UTC, David Strupl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2002-12-16 19:40:41 UTC
I am pretty sure I have seen this deadlock a bunch
of other times. Seems to be associated with module
reloading, or probably more generally with loader
pool changes.

Note that two threads are both waiting to use the
validator, and no one is actually using it.

I see a possible error in the logic in enter/exit:

1. Thread T1 calls enter().

2. T1 begins body of revalidate (or
removeInvalidObject, whichever).

3. T2 calls enter() and blocks because current == T1.

4. T3 calls enter() and blocks for the same reason.

5. T1 calls exit() and sets current == null.

6. T2 is notified, sees current == null,
continues, exits.

T3 is still blocked and will never continue.

Suggest that notify() be replaced with
notifyAll(). (Or, this whole awful system cleaned
up...)
Comment 1 Jesse Glick 2002-12-16 19:41:26 UTC
Created attachment 8352 [details]
Thread dump
Comment 2 Jesse Glick 2002-12-16 19:42:01 UTC
Sorry, forgot to mention: [dev dec 14].
Comment 3 David Strupl 2003-01-06 13:27:36 UTC
*** Issue 25605 has been marked as a duplicate of this issue. ***
Comment 4 David Strupl 2003-01-06 14:30:24 UTC
*** Issue 29809 has been marked as a duplicate of this issue. ***
Comment 5 David Strupl 2003-01-06 15:13:05 UTC
*** Issue 28648 has been marked as a duplicate of this issue. ***
Comment 6 David Strupl 2003-01-08 10:30:58 UTC
Jesse, your evaluation is not correct. You forgot about

7. T2 calls exit, sets current == null and notifies T3.

Also your suggestion would have no impact because if you would
notifyAll the other threads would end up in the wait because of the
while loop.

I will try to investigate the reason for the deadlock - I have no idea
yet.
Comment 7 David Strupl 2003-01-08 10:32:17 UTC
I am adding Jarda and Radek to Cc: for possible reviews, ideas etc.
Comment 8 David Strupl 2003-01-08 13:48:11 UTC
The real problem is in those facts:

1. org.openide.loaders.DataObjectPool$Validator.enter
is not reentrant (as noted by the genial comment inside the method)

2. there is a thread trying to reenter enter() - this thread causes
the other threads to freeze (in Jesses's thread dump this is thread
"OpenIDE-request-processor-0")

I suggest following fix: the thread would remember the number of times
it went through enter. This number would be increased in enter and
decreased in exit. In exit the other threads would be notified only in
case the counter is zero. Will attach a patch.

Please comment the idea - I am not sure enough and don't want screw up
things.
Comment 9 Jesse Glick 2003-01-08 14:59:10 UTC
dstrupl - You're right, that sounds like the explanation for the deadlock.

Rather than patching this already complex code, could it just be
simplified dramatically by using Mutex? The Validator class Javadoc
fails to explain what the actual requirements for its execution are.
It seems to have a number of special behaviors whose purpose is unclear.
Comment 10 David Strupl 2003-01-08 16:02:21 UTC
Created attachment 8473 [details]
Proposed patch
Comment 11 David Strupl 2003-01-08 16:05:32 UTC
I didn't want to do the rewrite - I am trying to keep the changes as
small as possible to be able to easily rollback. I hope to come with
new ds - so I am trying to limit the changes to the old system. Simply
put I have never found enough courage to do bigger changes to the
validation (or recognition). I feel I don't understand the whole
system enough to be able to do the changes (in reasonable amount of time).
Comment 12 David Strupl 2003-01-09 09:20:52 UTC
Fixed in trunk in DataObjectPool.java 1.72
Comment 13 David Strupl 2003-01-14 07:46:07 UTC
*** Issue 25032 has been marked as a duplicate of this issue. ***
Comment 14 Jesse Glick 2003-01-14 15:21:11 UTC
Is DataObjectInvalidationTest stable again (cf. issue #25032)?
Comment 15 David Strupl 2003-01-14 15:34:52 UTC
The deadlock is gone. But alas - ConcurrentModificationException
during the test. I will check it (again <sigh/>).
Comment 16 David Strupl 2003-01-14 16:49:25 UTC
I will refine the patch. Note that the exception occurs only in cases
where there used to be deadlock. So it is sort of safe to leave the
source as it is now and I will come back to this tomorrow.
Comment 17 David Strupl 2003-01-15 13:28:55 UTC
Better fix in DataObjectPool 1.73. Not ideal - I know.
Comment 18 David Strupl 2003-01-15 13:32:28 UTC
DataObjectInvalidationTest moved back to stable config.
Comment 19 David Strupl 2003-03-07 14:20:18 UTC
*** Issue 31775 has been marked as a duplicate of this issue. ***
Comment 20 David Strupl 2003-03-07 14:22:06 UTC
The last fix in DataObjectPool has to be improved with regards of
catching the exceptions. Please see #31775. I will try to move the try
block to include the line causing the problem.
Comment 21 David Strupl 2003-03-10 16:27:02 UTC
I will improve the fix but I leave this one as FIXED as it is no
longer deadlock. I will reopen #31775 and make the improvement of the
fix as fix of that one.
Comment 22 pzajac 2003-07-05 10:44:12 UTC
verified. The deadlock dodn't occured again for long time.