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 37767 - Deadlock in DocumentLine
Summary: Deadlock in DocumentLine
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 3.x
Hardware: PC Linux
: P1 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: THREAD
Depends on:
Blocks:
 
Reported: 2003-12-04 23:57 UTC by Jesse Glick
Modified: 2008-12-22 17:49 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Thread dump (11.68 KB, text/plain)
2003-12-04 23:57 UTC, Jesse Glick
Details
Fixes ordering of locks (2.01 KB, patch)
2003-12-08 15:08 UTC, Jaroslav Tulach
Details | Diff
Happened to me again, new thread dump (10.90 KB, text/plain)
2003-12-08 16:35 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2003-12-04 23:57:26 UTC
Probably not reproducible. Occurred while editing.
Data loss.
Comment 1 Jesse Glick 2003-12-04 23:57:54 UTC
Created attachment 12429 [details]
Thread dump
Comment 2 Jesse Glick 2003-12-04 23:58:14 UTC
Current dev sources.
Comment 3 Jesse Glick 2003-12-05 19:52:01 UTC
Happened to me again. Also while editing text. Again, data loss.
Comment 4 _ ttran 2003-12-07 21:52:18 UTC
too bad, Petr Nejedly is on vacation until the end of Dec.  Yarda,
please investigate.

Mila: can this be related to the threading changes you made in
openide/text and editor recently?

Thanks
Comment 5 Jaroslav Tulach 2003-12-08 15:08:30 UTC
Created attachment 12460 [details]
Fixes ordering of locks
Comment 6 Jaroslav Tulach 2003-12-08 15:13:23 UTC
I tried to simulate the deadlock but I have failed as there is not a
way how to hook into the code and one would have to rely on a luck.

Anyway I think I understand the problem and I have a fix. The cause of
the deadlock is a code that under private lock manipulates with
private HashMap, but this triggers DocumentLine.equals which asks for
rendering lock. 

I have not found a way to prevent the DocumentLine.equals to call
outside of the synchronized block, so I decided to order locks: before
the private lock is obtained, the DocumentLine.Set obtains rendering
lock first, this way any call to DocumentLine.equals has to
successfully succeed, as the lock is already being held.

Please review.
Comment 7 Jesse Glick 2003-12-08 16:35:13 UTC
Created attachment 12461 [details]
Happened to me again, new thread dump
Comment 8 Jaroslav Tulach 2003-12-08 17:16:19 UTC
With or without the patch? From what I see in DefaultRP, without. As
you seem to be able to reproduce this problem really often, you might
consider applying the patch to try to run to the same problems with it.
Comment 9 Miloslav Metelka 2003-12-08 17:41:26 UTC
I think Yarda's patch should fix the problem.
Unless I have overlooked anything the two threads are counter-locking
on doc-read-lock and Line.Set.lines. The attached fix should enter the
monitors in the same order.
Comment 10 Jaroslav Tulach 2003-12-08 18:36:22 UTC
DocumentLine 1.52
Comment 11 Jesse Glick 2003-12-08 20:46:05 UTC
OK, I will let you know if it reappears (I am running with the patch
now). Thanks for the quick patch.
Comment 12 Lukas Hasik 2004-02-26 14:38:41 UTC
verifying, Jesse is silence from 2003-12-08 and so I belive it's gone