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 246893

Summary: deadlock during Go To Symbol
Product: platform Reporter: Vladimir Voskresensky <vv159170>
Component: FilesystemsAssignee: Jaroslav Havlin <jhavlin>
Status: RESOLVED FIXED    
Severity: normal CC: gteichrow
Priority: P2    
Version: 8.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: threads dump
Proposed Patch

Description Vladimir Voskresensky 2014-09-05 10:38:08 UTC
I pressed Ctrl+Shift+O and IDE became frozen.
I see blocked Watcher.register in EDT
Comment 1 Vladimir Voskresensky 2014-09-05 10:39:03 UTC
Created attachment 149048 [details]
threads dump

  Product Version         = NetBeans IDE Dev (Build 20140905-ecb25fa5bd60) (#ecb25fa5bd60)
  Operating System        = SunOS version 5.11 running on amd64
  Java; VM; Vendor        = 1.7.0_67; Java HotSpot(TM) 64-Bit Server VM 24.65-b04; Oracle Corporation
  Runtime                 = Java(TM) SE Runtime Environment 1.7.0_67-b01
  Java Home               = /usr/jdk/instances/jdk1.7.0_67/jre
Comment 2 Ondrej Vrabec 2014-09-05 11:09:44 UTC
there is no deadlock, but VCSFileProxy should definitely not trying to add listeners in EDT
Comment 3 Jaroslav Havlin 2014-09-05 11:53:37 UTC
Unfortunately, I think there is a deadlock involving Watcher and FileChangedManager.

Thread "Refresh-After-WindowActivated" wants to perform some low-priority I/O operation using "FileChangedManager.idleIO". In this operation, it needs to register a listener, so it takes Watcher's lock, but it is then blocked in FileChangedManager because it is waiting for some (just started) hi-priority operation to complete.

Thread "org.netbeans.modules.jumpto.symbol.ContentProviderImpl" performs the high-priority operation (FileChangedManager.priorityIO), but it cannot complete it as it has to wait forever to get the Watcher's lock (meanwhile retrieved by "Refresh-After-WindowActivated").

This deadlock can occur only with NIO2 Notifier (currently used probably only on Solaris OS) which invokes Java SecurityManager when registering a watch. (FileChangedManager is set as SecurityManager in NetBeans.)
Comment 4 Ondrej Vrabec 2014-09-05 12:16:48 UTC
ok, then. Fix the deadlock and then reassign back to me, because the I/O in EDT should be avoided as well.
Comment 5 Jaroslav Havlin 2014-09-08 12:47:33 UTC
Created attachment 149065 [details]
Proposed Patch

Patch that fixes the problem. Reviews are welcome.
I'll integrate it at the end of this week, unless there are any objections.
Comment 6 Jaroslav Havlin 2014-09-11 13:04:38 UTC
Fixed - http://hg.netbeans.org/core-main/rev/8908192d8d66

If you want to integrate the fix in the patch (801patch1-candidate), please verify if carefully (especially on Solaris). If the change breaks something, the impact can be quite large.
Thank you.
Comment 7 Jaroslav Havlin 2014-09-11 13:11:55 UTC
(In reply to Ondrej Vrabec from comment #4)
> ok, then. Fix the deadlock and then reassign back to me, because the I/O in
> EDT should be avoided as well.
Reported as separate bug 247030.
Comment 8 Quality Engineering 2014-09-13 04:52:39 UTC
Integrated into 'main-silver', will be available in build *201409130001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/8908192d8d66
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #246893: Deadlock during Go To Symbol

FileChangedManager's "lock" has to be always taken before Watcher's lock.
Comment 9 Jaroslav Havlin 2015-08-12 08:29:48 UTC
*** Bug 252393 has been marked as a duplicate of this bug. ***