Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Dead-lock while starting NetBeans #23

Closed
basiliscus opened this Issue · 25 comments

2 participants

basiliscus Attila Kelemen
basiliscus

I've recently upgraded to a newer revision of the plugin (716e795), and the custom tasks functionality seems to be broken.
I right-click on the project, select the "Custom tasks" submenu, but do not see any of my custom tasks there. Despite the tasks are defined in .nb-gradle-properties and they used to work.

Also, sometimes the plugin breaks something and Netbeans starts hanging on startup. I have to restore the IDE settings folder from time machine to bring it to life again.
Not sure if those events are related, but it seems to me that the custom tasks editing dialog causes the corruption. At least, for the last time it happened right aftter that.

Attila Kelemen
Owner

To me custom tasks seem to work. Can you tell me what is your custom task definition?

Netbeans starts hanging on startup

Is this means that NetBean hangs on the splash screen? Have you used 1.1.7 as well and you did not experience it there? Anyway, it seems unlikely that the problem is related to custom tasks. Also, this seems weird because the plugin should not do anything on startup. Can you deterministically reproduce this issue on your system?

Attila Kelemen
Owner

Also, do you have the logs of NetBeans when it hangs?

basiliscus

To me custom tasks seem to work. Can you tell me what is your custom task definition?

Oops... it seems I was wrong here.
My custom tasks look like this: :submodule1:gwtcompile . I expected the task would be available on every submodule node, but in fact it was available on submodule1 only.
Please disregard it, my bad.

Is this means that NetBean hangs on the splash screen?

Exactly.

Have you used 1.1.7 as well and you did not experience it there?

Not sure. This is not the first time I faced the problem, but I do not remember the conditions.

Also, this seems weird because the plugin should not do anything on startup.

I temporarily disabled the plugin by editing .netbeans/7.2/config/Modules/org-netbeans-gradle-project.xml , and that solved the problem. So this does seem to be the plugin issue.

Can you deterministically reproduce this issue on your system?

I'm trying to do that...

Also, do you have the logs of NetBeans when it hangs?

I started netbeans from command line when the problem occured, and there was nothing related in the console.
Is there any other place where I can look for netbeans logs?

Attila Kelemen
Owner

For tasks to be available everywhere you should uncheck "Task must exists", otherwise the plugin only checks the selected subproject and its child projects.

On Win7 the logs are stored in C:\Users<username>\AppData\Roaming\NetBeans\7.2\var\log\messages.log. NetBeans however only keeps logs from the last three runs. On *nix, I'm not sure but probably ~/NetBeans/7.2/var/log/messages.log

basiliscus

I have found the logs: I backed up the netbeans home folder right before restoring it from the time machine.
However, I do not see any errors there. If you think the logs maybe useful, how can I send it?

Attila Kelemen
Owner

A link to pastebin or a gist could be ok, just omit the initial enumeration of modules.

Although I have found a part which is dead-lock prone: org.netbeans.gradle.project.query.GradleSourceEncodingQuery. That is, if getEncoding is called from the EDT this method might dead-lock. I have had problems with character encoding in the past, so this is a notorious part of the code :). Anyway, the code is wrong, I will carefully examine it and will fix it.

Can you try to add a logging to this method and log if it is called from the EDT when NB hangs. So if you can reproduce the issue, you can examine the logs. I would try to reproduce the issue by "Run" the plugin, so it doesn't corrupt anything.

basiliscus

I haven't managed to recreate the corruption.
However, I can reproduce the hanging by restoring the corrupted content of netbeans home folder.

Can you instruct me how I can supply the corrupted folder to the "run" environment? After that I will be able to debug the issue.

Attila Kelemen
Owner

I have never tried if it works but NetBeans stores the environment for "run" in "build/testuserdir", if you can copy your NetBeans user directory there it might work.

basiliscus

Ok, it has worked: I've reproduced the hanging in the run environment.

As for your question whether the method was accessed, it was not. I used the following code:

@Override
public Charset getEncoding(FileObject file) {
    Exception e = new Exception("========================== "+file);
    e.printStackTrace(System.out);
    e.printStackTrace(System.err);
Attila Kelemen
Owner

Can you run the plugin in "debug", so that you can break and inspect the callstacks of the running threads?

basiliscus

One of the suspicious threads:

java.lang.Object.wait(Object.java)
java.lang.Object.wait(Object.java:485)
org.openide.util.Task.waitFinished(Task.java:135)
org.openide.util.RequestProcessor$Task.waitFinished(RequestProcessor.java:1708)
org.netbeans.modules.project.ui.OpenProjectList$LoadOpenProjects.get(OpenProjectList.java:511)
org.netbeans.modules.project.ui.OpenProjectList$LoadOpenProjects.get(OpenProjectList.java:265)
org.netbeans.modules.versioning.util.DelayScanRegistry.isDelayed(DelayScanRegistry.java:89)
org.netbeans.modules.git.FilesystemInterceptor$RefreshTask.run(FilesystemInterceptor.java:415)
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)

I'm digging further...

basiliscus

java.lang.Object.wait(Object.java)
java.lang.Object.wait(Object.java:485)
org.openide.util.Task.waitFinished(Task.java:135)
org.openide.util.RequestProcessor$Task.waitFinished(RequestProcessor.java:1708)
org.netbeans.modules.uihandler.Installer.writeOutMetrics(Installer.java:579)
org.netbeans.modules.uihandler.MetricsHandler$1WriteOut.run(MetricsHandler.java:80)
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)

Attila Kelemen
Owner

NetBeans has this "check for deadlock" button in the debug menu. Does it report anything (it never worked for me though)?

basiliscus

Some more items. Niether of the stack traces seem to be related to the plugin.
And the magic button didn't work :)

java.lang.Object.wait(Object.java)
java.lang.Object.wait(Object.java:485)
org.netbeans.modules.uihandler.Installer$SubmitAutomatic.showDialogAndGetValue(Installer.java:2491)
org.netbeans.modules.uihandler.Installer$Submit.run(Installer.java:1752)
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)

java.lang.Object.wait(Object.java)
java.lang.Object.wait(Object.java:485)
java.awt.EventQueue.invokeAndWait(EventQueue.java:1106)
org.netbeans.modules.uihandler.Installer.parseButtons(Installer.java:1124)
org.netbeans.modules.uihandler.Installer$Submit.doShow(Installer.java:1644)
org.netbeans.modules.uihandler.Installer.displaySummary(Installer.java:1021)
org.netbeans.modules.uihandler.Installer.access$400(Installer.java:113)
org.netbeans.modules.uihandler.Installer$2Auto.run(Installer.java:575)
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1452)
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2032)

Attila Kelemen
Owner

Which of these threads is the EDT?

Attila Kelemen
Owner

Can you create a thread dump, though seeing all the variables would be better but it might help.

basiliscus

I don't see any EDT thread. However, the "AWT event queue" thread seems to be what we are looking for:

sun.misc.Unsafe.park(Unsafe.java)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)
org.netbeans.gradle.project.WaitableSignal.tryWaitForSignal(WaitableSignal.java:39)
org.netbeans.gradle.project.properties.ProjectPropertiesProxy.tryWaitForLoaded(ProjectPropertiesProxy.java:88)
org.netbeans.gradle.project.NbGradleProject.tryGetLoadedProperties(NbGradleProject.java:208)
org.netbeans.gradle.project.query.GradleSourceEncodingQuery.getEncoding(GradleSourceEncodingQuery.java:21)
org.netbeans.modules.projectapi.ProjectFileEncodingQueryImplementation.getEncoding(ProjectFileEncodingQueryImplementation.java:76)
org.netbeans.api.queries.FileEncodingQuery.getEncoding(FileEncodingQuery.java:94)
org.openide.text.DataEditorSupport.openDocument(DataEditorSupport.java:583)
org.apache.tools.ant.module.xml.AntProjectSupport.parseDocument(AntProjectSupport.java:271)
org.apache.tools.ant.module.xml.AntProjectSupport.getDocument(AntProjectSupport.java:161)
org.apache.tools.ant.module.xml.AntProjectSupport.getProjectElement(AntProjectSupport.java:316)
org.apache.tools.ant.module.loader.AntProjectDataEditor.annotateWithProjectName(AntProjectDataEditor.java:121)
org.apache.tools.ant.module.loader.AntProjectDataEditor.messageHtmlName(AntProjectDataEditor.java:110)
org.openide.text.CloneableEditor$1.run(CloneableEditor.java:1114)
org.openide.util.Mutex.doEvent(Mutex.java:1343)
org.openide.util.Mutex.writeAccess(Mutex.java:457)
org.openide.text.CloneableEditor.updateName(CloneableEditor.java:1111)
org.netbeans.core.spi.multiview.text.MultiViewCloneableEditor.updateName(MultiViewCloneableEditor.java:186)
org.openide.text.CloneableEditor.readExternal(CloneableEditor.java:1218)
org.openide.windows.TopComponent$Replacer.readObject(TopComponent.java:1797)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:969)
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
org.netbeans.core.multiview.MultiViewPeer.peerReadExternal(MultiViewPeer.java:547)
org.netbeans.core.multiview.MultiViewCloneableTopComponent.readExternal(MultiViewCloneableTopComponent.java:222)
org.openide.windows.TopComponent$Replacer.readObject(TopComponent.java:1797)
sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:969)
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
org.netbeans.modules.settings.convertors.XMLSettingsSupport$SettingsRecognizer.readSerial(XMLSettingsSupport.java:549)
org.netbeans.modules.settings.convertors.XMLSettingsSupport$SettingsRecognizer.instanceCreate(XMLSettingsSupport.java:581)
org.netbeans.modules.settings.convertors.SerialDataConvertor$SettingsInstance.instanceCreate(SerialDataConvertor.java:424)
org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentPersistentForID(PersistenceManager.java:571)
org.netbeans.core.windows.persistence.PersistenceManager.getTopComponentForID(PersistenceManager.java:681)
org.netbeans.core.windows.PersistenceHandler.getTopComponentForID(PersistenceHandler.java:489)
org.netbeans.core.windows.PersistenceHandler.load(PersistenceHandler.java:156)
org.netbeans.core.windows.WindowSystemImpl.load(WindowSystemImpl.java:81)
org.netbeans.core.GuiRunLevel$InitWinSys.run(GuiRunLevel.java:234)
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:702)
java.awt.EventQueue.access$400(EventQueue.java:82)
java.awt.EventQueue$2.run(EventQueue.java:663)
java.awt.EventQueue$2.run(EventQueue.java:661)
java.security.AccessController.doPrivileged(AccessController.java)
java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
java.awt.EventQueue.dispatchEvent(EventQueue.java:672)
org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Attila Kelemen
Owner

Yes, this should be the EDT and I will try to figure out what is going on.

Attila Kelemen
Owner

And as I suspected: GradleSourceEncodingQuery.getEncoding is called on the EDT. This is rather problematic but I will try do something.

Attila Kelemen
Owner

I think this change should fix the issue you are having. Anyway, I don't know why this issue doesn't manifest more frequently.

basiliscus

Unfortunately, it doesn't seem to be solved.
1. I pulled the sources and rebuilt the nbm.
2. Disabled the gradle plugin in my "bad" userdir and started Netbeans from there.
3. Closed all projects (to ensure that the issue is not project-related).
4. Uninstalled and reinstalled the plugin.
5. After restart netbeans hanged again :(

Attila Kelemen
Owner

I have just realized that I forgot something ... Will fix it soon. I think after this fix I will test the plugin and will release 1.1.8 and not wait for other features I wanted to add. This is a nasty issue.

Attila Kelemen
Owner

Hopefully I have removed all invokeLater from loading properties. Can you check if this finally works?

basiliscus

Yes, the issue seems to be fixed now.
Thank you for fixing it so quickly and for all your efforts on this plugin.

Attila Kelemen
Owner

I'm glad it was fixed, since preventing NetBeans from loading is rather serious. Thank you for helping to track down this one. Now, I 'll test this for a few days and upload it to the Plugin Portal.

Attila Kelemen kelemen closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.