satyagraha / gfm_viewer

An Eclipse plugin providing an accurate view of GitHub Flavored Markdown (.md) files
95 stars 27 forks source link

3 NPE when switching to Debug Perspective #20

Closed paulvi closed 11 years ago

paulvi commented 11 years ago

Steps to reproduce

  1. Install Node.js http://www.nodejs.org/download/
  2. Download latest Eclipse Kepler 4.3.1 http://www.eclipse.org/downloads/
  3. Install Nodeclipse http://www.nodeclipse.org/
  4. Switch to Node perspective
  5. open GFM View
  6. Create new Node project
  7. Right-click hello-word-server.js -> Debug as -> Node.js app
  8. When switched, Dialog with 3 Null Pointer Exceptions is shown.

error-1341-gfmview2istrackable

eclipse.buildId=4.3.0.I20130605-2000
java.version=1.7.0_25
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32
Framework arguments:  -product org.eclipse.epp.package.dsl.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.dsl.product

Error
Tue Oct 01 13:39:41 CST 2013
Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".

java.lang.NullPointerException
    at code.satyagraha.gfm.viewer.views.GfmView$2.isTrackableFile(GfmView.java:88)
    at code.satyagraha.gfm.viewer.views.EditorTracker.checkIfTrackable(EditorTracker.java:111)
    at code.satyagraha.gfm.viewer.views.EditorTracker.partActivated(EditorTracker.java:62)
    at org.eclipse.ui.internal.PartService$6.run(PartService.java:131)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.PartService.partActivated(PartService.java:129)
    at org.eclipse.ui.internal.WorkbenchPage$15.run(WorkbenchPage.java:4798)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.WorkbenchPage.firePartActivated(WorkbenchPage.java:4796)
    at org.eclipse.ui.internal.WorkbenchPage.access$16(WorkbenchPage.java:4776)
    at org.eclipse.ui.internal.WorkbenchPage$E4PartListener.partActivated(WorkbenchPage.java:195)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl$2.run(PartServiceImpl.java:183)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.firePartActivated(PartServiceImpl.java:181)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:595)
    at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.activate(PartServiceImpl.java:539)
    at org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer.activate(AbstractPartRenderer.java:104)
    at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer$1.handleEvent(ContributedPartRenderer.java:59)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1081)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
    at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1453)
    at org.eclipse.swt.widgets.Shell.WM_MOUSEACTIVATE(Shell.java:2334)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4655)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
    at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1627)
    at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2075)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
    at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
    at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)
    at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3141)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
paulvi commented 11 years ago

I also got once the same Exception when right-click select Generate Markdown Preview from within Editor.

satyagraha commented 11 years ago

These NPE's are most likely arising due to some anomalies in how the life-cycle for the GfmView class is being handled. Eclipse views aren't meant to have regular constructors, rather the createPartControl and dispose methods should manage its state. I think calls are being made to methods like generateIFolder after dispose has been called, and as this latter method sets the gfmTransformer instance variable to null (to free garbage) an NPE will occur for every file in the folder.

satyagraha commented 11 years ago

The NPE's also happens if the view has been constructed, but createPartControl has not been called - which can happen!

A fair bit of refactoring will be required to disentangle the responsibilities of this class...

paulvi commented 11 years ago

Since I have been using GFM Viewer, I think I have not run into this error. So it may be introduced with newer changes (as it often happens).. But you are to know better where ...

For me also it seems that to dispose View with Browser inside (and then create it again) is resource waste. Not to mention that because of using native code, the may be memory leaks and some instabilities. Is it possible to have gradual dispose?

paulvi commented 11 years ago

BTW, I wonder is 10 times the snippet below a Eclipse bug? It is really excessive.

at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2544)
at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4706)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:340)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4990)

If we can reproduce we should report.

paulvi commented 11 years ago

Raised bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=418511

satyagraha commented 11 years ago

Fixed in 1.4.0.