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 214647

Summary: Reproducible deadlock oracle.cloud vs. non-native keyrings?
Product: javaee Reporter: Martin Fousek <marfous>
Component: Oracle CloudAssignee: David Konecny <dkonecny>
Status: VERIFIED FIXED    
Severity: normal CC: jskrivanek, mmirilovic, phejl, pjiricka
Priority: P2    
Version: 7.2   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: threaddump
messages.log
possible untested fix
alternative
web project patch
j2ee instances fix

Description Martin Fousek 2012-06-22 19:55:39 UTC
Created attachment 121232 [details]
threaddump

Product Version         = NetBeans IDE Dev (Build 20120622-20343bc64e27)
Operating System        = Linux version 3.0.0-20-generic running on amd64
Java; VM; Vendor        = 1.6.0_26; Java HotSpot(TM) 64-Bit Server VM 20.1-b02;

The native keyring doesn't work in my environment and now always when I'm trying to start the IDE, it freezes after the module initialization. I'm attaching threaddump created by jstack and the messages.log.

Thanks in advance.
Comment 1 Martin Fousek 2012-06-22 19:59:06 UTC
Created attachment 121233 [details]
messages.log
Comment 2 Petr Hejl 2012-06-23 09:42:43 UTC
What JDK do you use? We have recently seen some mysterious AWT related bugs.

From the threadump - obviously fallback keyring cannot proceed as it is waiting for AWT thread.

_However_ AWT thread is holding only one monitor and it is waiting on the same monitor which it already owns. Really strange. I do not see any reason why AWT should not proceed.

   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x00000000d1398b40> (a java.util.WeakHashMap)
	at java.lang.Object.wait(Object.java:485)
	at org.netbeans.api.project.ProjectManager$2.run(ProjectManager.java:254)
	- locked <0x00000000d1398b40> (a java.util.WeakHashMap)
	at org.netbeans.api.project.ProjectManager$2.run(ProjectManager.java:234)
	at org.openide.util.Mutex.readAccess(Mutex.java:332)

Is this really thread dump from the moment IDE is deadlocked?
Comment 3 Petr Hejl 2012-06-23 10:09:01 UTC
Ok now I got it (so we can ignore comment #2 ;) ). AWT is waiting in loop (on wait()) in ProjectManager for project to be loaded. "ErrorAnnotator worker" seems to be loading the project and it needs keyring and the keyring needs AWT -> deadlock.

It has never been a good idea to call Keyring on startup. If possible, it should be avoided.
Comment 4 Petr Hejl 2012-06-23 10:20:30 UTC
Could this org.netbeans.modules.cloud.oracle.OracleInstanceManager.load be called lazily from org.netbeans.modules.cloud.oracle.serverplugin.OracleOptionalDeploymentManagerFactory.finishServerInitialization?
Comment 5 Petr Hejl 2012-06-23 20:30:44 UTC
Created attachment 121255 [details]
possible untested fix

This could be one possible way of fixing this. It is a blind fix which has not been tested.
Comment 6 David Konecny 2012-06-24 19:31:41 UTC
Patch looks good to me - delaying keyring access makes sense as it is not needed at that moment. Martin could you apply the patch and verify that it solves your problem? If so just push it please. Thx.
Comment 7 Petr Hejl 2012-06-24 20:55:38 UTC
One thing that came to my mind later is that perhaps it would make sense to load username and password in the patch together as the common case is these are need together.
Comment 8 Petr Hejl 2012-06-24 21:05:29 UTC
Created attachment 121265 [details]
alternative

I mean something like this. Though the original patch should work as well.
Comment 9 David Konecny 2012-06-24 22:36:00 UTC
Are there some exact steps how to reproduce it? What triggers UI dialog in keyring API? From stack trace it look like some window with a deployment descriptor are being deserialized during IDE startup. I wonder how many user are impacted by this problem and whether we should try to resolve this in 7.2 or not. I tried to reproduce it but without success.
Comment 10 Martin Fousek 2012-06-25 05:18:20 UTC
(In reply to comment #9)
> Are there some exact steps how to reproduce it? What triggers UI dialog in
> keyring API? 

Exact steps? Not sure on your environment. I have opened at least one project with Oracle Cloud Remote instance and broken native keyrings, see:

FINEST [org.netbeans.modules.keyring]: reading: org.netbeans.modules.cloud.oracle.username.Oracle Cloud
FINE [org.netbeans.modules.keyring.kde.KWalletProvider]: executing [qdbus, org.kde.kwalletd, /modules/kwalletd, org.kde.KWallet.isEnabled]
FINE [org.netbeans.modules.keyring.kde.KWalletProvider]: application exit with code 2 for commandString: [qdbus, org.kde.kwalletd, /modules/kwalletd, org.kde.KWallet.isEnabled]; errVal: Service 'org.kde.kwalletd' does not exist.
FINE [org.netbeans.modules.keyring.gnome.GnomeProvider]: no GNOME_KEYRING_* environment variable set
FINE [org.netbeans.modules.keyring.win32.Win32Protect]: not running on Windows

> From stack trace it look like some window with a deployment
> descriptor are being deserialized during IDE startup.

Sorry, really don't know about anything special. But agree that the issue shouldn't be facing plenty of users.

Anyway I tried both patches and both of them worked well and prevent the IDE from freezing. I'll settle the pushing with phejl today.
Comment 11 Petr Hejl 2012-06-25 06:43:35 UTC
From the thread dump I would expect these are preconditions:
- cloud project
- -J-Dnetbeans.keyring.no.native=true
- opened task list (or what's the current name for the old task list)
Comment 12 Petr Hejl 2012-06-25 08:07:16 UTC
Fixed in web-main 3892095d33f7.

Jirko can you verify?
Comment 13 Petr Hejl 2012-06-25 19:45:05 UTC
As discussed with Jirka the patch unfortunately introduced the "Resolve missing server dialog" (and by looking to the code, perhaps WhiteListUpdater would not be properly initialized due to missing J2eePlatform).

I investigated the higher parts of call stack and noticed that WhiteListUpdater is registering itself as a listener from WebProject constructor. Perhaps it's too early so I tried to postpone it to phase when the project is really going to be opened. I can't verify right now whether this really helps (as Matej requires my attention :) ). However it might be a way. Attaching the patch against 8497d0a2f749 (the parent of unsuccessful patch) so try with "hg up -r 8497d0a2f749 && patch -p1 < the.patch".
Comment 14 Petr Hejl 2012-06-25 19:47:21 UTC
Created attachment 121317 [details]
web project patch
Comment 15 David Konecny 2012-06-25 23:05:32 UTC
(In reply to comment #13)
> As discussed with Jirka the patch unfortunately introduced the "Resolve missing
> server dialog" (and by looking to the code, perhaps WhiteListUpdater would not
> be properly initialized due to missing J2eePlatform).

Really? How?? I cannot see any functional change in the patch which could cause 'Resolve ...' dialog nor impact WhiteListUpdater. We just delayed loading of data from keyring. Am I missing something?

If there is a 'Resolve ...' dialog problem then it must be a independent issue I think which existed before.
Comment 16 Quality Engineering 2012-06-26 04:57:14 UTC
Integrated into 'main-golden', will be available in build *201206260002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/3892095d33f7
User: Petr Hejl <phejl@netbeans.org>
Log: #214647 Reproducible deadlock oracle.cloud vs. non-native keyrings?
Comment 17 Jiri Skrivanek 2012-06-26 07:21:04 UTC
Verified in dev build 201206260002 using following steps:

- start IDE with empty userdir and -J-Dnetbeans.keyring.no.native=true
- register Oracle cloud
- create java web project with Oracle Cloud Remote target server (add JSF
framework in wizard)
- open Window|Action Items
- restart IDE
- it does not freeze but "Resolve missing server" dialog is opened and you have
to provide master password to get rid of it which is not pleasant. But if there
is no other possibility how to fix it we can live with that.
Comment 18 Petr Hejl 2012-06-26 08:52:50 UTC
(In reply to comment #15)
> (In reply to comment #13)
> > As discussed with Jirka the patch unfortunately introduced the "Resolve missing
> > server dialog" (and by looking to the code, perhaps WhiteListUpdater would not
> > be properly initialized due to missing J2eePlatform).
> 
> Really? How?? I cannot see any functional change in the patch which could cause
> 'Resolve ...' dialog nor impact WhiteListUpdater. We just delayed loading of
> data from keyring. Am I missing something?
I've investigated bit more. We have delayed it and the keyring appears when initializing j2ee api instances OracleJ2EEServerInstanceProvider.refreshServersSynchronously(). So before it stopped the j2ee ServerRegistry (with possibility of deadlock). Now the j2ee server registry init proceeds and later IDE stops at asynch j2ee instances initalization.

> 
> If there is a 'Resolve ...' dialog problem then it must be a independent issue
> I think which existed before.
Yes I think, though it was not visible.
Comment 19 Petr Hejl 2012-06-26 08:58:05 UTC
Created attachment 121346 [details]
j2ee instances fix

This patch "solves" the Missing server dialog issue. The dialog do not appear although I believe there is still possible race. The patch removes the duplication of username and password in j2ee part. As an additional benefit the keyring password is not requested until it is really needed (so no keyring dialog after IDE start).

David as you are the owner you should decide whether this should be part of the solution or whether this is separate P3.

I tested the solution and it seems to work ok.
Comment 20 Petr Hejl 2012-06-26 21:10:53 UTC
(In reply to comment #19)
> Created attachment 121346 [details]
> j2ee instances fix
> 
> This patch "solves" the Missing server dialog issue. The dialog do not appear
> although I believe there is still possible race. The patch removes the
> duplication of username and password in j2ee part. As an additional benefit the
> keyring password is not requested until it is really needed (so no keyring
> dialog after IDE start).
> 
> David as you are the owner you should decide whether this should be part of the
> solution or whether this is separate P3.
> 
> I tested the solution and it seems to work ok.

I filed separate issue #214827.
Comment 21 David Konecny 2012-06-26 21:36:06 UTC
changeset:   232295:6bb30be02ab3
branch:      release72
user:        Petr Hejl <phejl@netbeans.org>
date:        Mon Jun 25 10:05:51 2012 +0200
files:       cloud.oracle/src/org/netbeans/modules/cloud/oracle/OracleInstance.java cloud.oracle/src/org/netbeans/modules/cloud/oracle/OracleInstanceManager.java
description:
#214647 Reproducible deadlock oracle.cloud vs. non-native keyrings?
(transplanted from 3892095d33f77c5ff9259dc58f9c4bf47284e487)
Comment 22 Quality Engineering 2012-06-28 05:08:35 UTC
Integrated into 'releases', will be available in build *201206272359* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/6bb30be02ab3
User: Petr Hejl <phejl@netbeans.org>
Log: #214647 Reproducible deadlock oracle.cloud vs. non-native keyrings?
(transplanted from 3892095d33f77c5ff9259dc58f9c4bf47284e487)
Comment 23 Jiri Skrivanek 2012-06-28 08:12:18 UTC
Verified in NetBeans IDE 7.2 RC1 (Build 201206272359).