pmd / pmd-eclipse-plugin

The pmd-eclipse-plugin integrates the source code analyzer PMD into the Eclipse IDE
Other
93 stars 43 forks source link

Eclipse nearly-consistently crashes on startup when workspace contains PMD enabled projects #148

Closed krallus closed 3 years ago

krallus commented 3 years ago

When the PMD plugin is installed in Eclipse and the workspace contains a project with PMD enabled, Eclipse will crash when it starts up. Less commonly, Eclipse will freeze during startup and require a "force quit". After several attempts (in the range of 3 to 10, sometimes more), Eclipse will eventually start without crashing. I often notice "deferred early start" in the Eclipse status bar when it does start successfully. This may hint that there is a timing issue in the loading of the PMD plugin.

Important to note is that this only happens when the the projects that have PMD enabled have "Use the ruleset configured in a project file" enabled. (In my case, I have four projects that all reference the same external ruleset file). It doesn't seem to matter what the precise contents of the ruleset file are.

I know that the Eclipse crash is related to the PMD plugin because performing any one of the following will allow Eclipse to start normally:

On those attempts where Eclipse starts without crashing, everything, including the PMD plugin work completely fine and as expected.

I have attempted to resolve this by installing a fresh installation of Eclipse and using a clean new workspace, but as soon as I have a PMD enabled project that points to a custom ruleset file, this crash will start happening. I have been unsuccessful in narrowing it down further, unfortunately. I will also note here that the projects that have PMD enabled are Maven projects.

Environment:

UPDATE: I confirmed that the issue occurs for all versions of the PMD Eclipse Plugin, back to at least as far as 4.20.0.v20210130-1744 (I did not test earlier versions), when the plugin is installed to Eclipse 2021-06 (4.20.0).

A simple workspace that exhibits this problem: https://www.dropbox.com/s/hjgxkndbgccr2k3/pmd-test.tar.gz?dl=0 You may get lucky and it will open fine the first time, but after a few exits and restarts, Eclipse will crash.

adangel commented 3 years ago

Hi @krallus ,

Unfortunately I can't reproduce the problem. As you said, there is no error at all, when eclipse crashes... the log in .metadata/.log doesn't show a specific error (except for SWT resources, for which I created #153).

I noticed, that you use a ubuntu flavor of java 11 for running eclipse. Can you try to use the standard eclipse from eclipse.org? Eclipse 2021-06 ships with Java 16 as runtime.

How do you start eclipse? Do you start it from a terminal, so that you can see any error when it crashes? Maybe there is a jvm crash - if this is the case, then this crash won't appear in eclipse's error log but only on the console (e.g. in stderr).

I often notice "deferred early start" ...

This is the initialization of oomph setting up your eclipse/workspace. It starts after a while. But your crash seem to happen mostly before that. So I guess, this is unrelated. If you are interested to know, what is happening during that phase, you can have a look at the file eclipse/configuration/org.eclipse.oomph.setup/setup.log.

krallus commented 3 years ago

[EDIT: I spoke too soon, it seems. Starting Eclipse from within a terminal can also result in a crash. I must have just been "lucky" when I tested it out earlier. I am editing this comment to reflect that fact and to avoid confusion...]

I have been launching Eclipse from the shortcut in the Linux Mint Cinnamon menu. The shortcut specifies the following command: env GTK_IM_MODULE=ibus /home/hacheyp/opt/eclipse/jee/eclipse/eclipse Running this command from a terminal produces the following results... 1) In those cases where Eclipse successfully launches OR when it hangs on starting up, the terminal shows:

org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized.  Will retry after the state location is initialized.
org.eclipse.m2e.logback.configuration: Logback config file: /home/hacheyp/workspaces/jee/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.1.20210603-1006.xml
org.eclipse.m2e.logback.configuration: Initializing logback
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  1. In those cases where Eclipse crashes (the majority of the time) -- the window disappears and (usually) is replaced by a window that shows all of Eclipse's arguments/parameters -- then the terminal shows:
    org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized.  Will retry after the state location is initialized.
    org.eclipse.m2e.logback.configuration: Logback config file: /home/hacheyp/workspaces/jee/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.1.20210603-1006.xml
    org.eclipse.m2e.logback.configuration: Initializing logback
    Gdk-Message: 10:27:41.753: Eclipse: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

    An additional thing I will note here is that I always get the "select workspace" prompt on startup. It's only after selecting a workspace that has a PMD enabled project that the crash occurs.

I have one other machine running Linux Mint. When I have some time, I'll do some testing there. I would love to know whether or not others using PMD and launching Eclipse in Cinnamon have experienced this problem.

krallus commented 3 years ago

For the record, I tried installing Java 16 -- the Linux distro version -- and running Eclipse under that but the problem persists. I'll test out a straight up downloaded Hotspot OpenJDK 16.

krallus commented 3 years ago

No dice with the OpenJDK 16 either.

downloaded from:

Here is Eclipse running in debug mode when the crash happens (that is, the crash where the window with all java arguments appears), though sadly I do not think it will be particularly helpful:

hacheyp@hacheyp-freshmint:~$ /home/hacheyp/opt/eclipse/jee/eclipse/eclipse -consolelog -debug
Start VM: /opt/java/jdk-16.0.1/bin/java
-Dosgi.requiredJavaVersion=11
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-Dsun.java.command=Eclipse
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true
-Xms256m
-Xmx2048m
--add-modules=ALL-SYSTEM
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
-jar /home/hacheyp/opt/eclipse/jee/eclipse//plugins/org.eclipse.equinox.launcher_1.6.200.v20210416-2027.jar
-os linux
-ws gtk
-arch x86_64
-showsplash /home/hacheyp/.p2/pool/plugins/org.eclipse.epp.package.common_4.20.0.20210612-1200/splash.bmp
-launcher /home/hacheyp/opt/eclipse/jee/eclipse/eclipse
-name Eclipse
--launcher.library /home/hacheyp/.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.200.v20210429-1609/eclipse_11401.so
-startup /home/hacheyp/opt/eclipse/jee/eclipse//plugins/org.eclipse.equinox.launcher_1.6.200.v20210416-2027.jar
--launcher.appendVmargs
-exitdata 68005
-product org.eclipse.epp.package.jee.product
-consolelog
-debug
-vm /opt/java/jdk-16.0.1/bin/java
-vmargs
-Dosgi.requiredJavaVersion=11
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-Dsun.java.command=Eclipse
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=11
-Dosgi.dataAreaRequiresExplicitInit=true
-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true
-Xms256m
-Xmx2048m
--add-modules=ALL-SYSTEM
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
-jar /home/hacheyp/opt/eclipse/jee/eclipse//plugins/org.eclipse.equinox.launcher_1.6.200.v20210416-2027.jar 
WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector
Install location:
    file:/home/hacheyp/opt/eclipse/jee/eclipse/
Configuration file:
    file:/home/hacheyp/opt/eclipse/jee/eclipse/configuration/config.ini loaded
Configuration location:
    file:/home/hacheyp/opt/eclipse/jee/eclipse/configuration/
Framework located:
    file:/home/hacheyp/.p2/pool/plugins/org.eclipse.osgi_3.16.300.v20210525-1715.jar
Loading extension: reference:file:org.eclipse.osgi.compatibility.state_1.2.400.v20210401-1438.jar
    eclipse.properties not found
Framework classpath:
    file:/home/hacheyp/.p2/pool/plugins/org.eclipse.osgi_3.16.300.v20210525-1715.jar
    file:/home/hacheyp/.p2/pool/plugins/
    file:/home/hacheyp/.p2/pool/plugins/org.eclipse.osgi.compatibility.state_1.2.400.v20210401-1438.jar
Splash location:
    /home/hacheyp/.p2/pool/plugins/org.eclipse.epp.package.common_4.20.0.20210612-1200/splash.bmp
Debug options:
    file:/home/hacheyp/.options not found
Time to load bundles: 6
org.eclipse.m2e.logback.configuration: The org.eclipse.m2e.logback.configuration bundle was activated before the state location was initialized.  Will retry after the state location is initialized.
Starting application: 1184
org.eclipse.m2e.logback.configuration: Logback config file: /home/hacheyp/workspaces/jee/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.16.1.20210603-1006.xml
org.eclipse.m2e.logback.configuration: Initializing logback
!SESSION 2021-07-13 13:05:35.235 -----------------------------------------------
eclipse.buildId=4.20.0.I20210611-1600
java.version=16.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_CA
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product -consolelog -debug

!ENTRY org.eclipse.jface 2 0 2021-07-13 13:05:41.518
!MESSAGE Keybinding conflicts occurred.  They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2021-07-13 13:05:41.518
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
Binding(CTRL+SHIFT+T,
    ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
        Open a type in a Java editor,
        Category(org.eclipse.ui.category.navigate,Navigate,null,true),
        org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@433362e0,
        ,,true),null),
    org.eclipse.ui.defaultAcceleratorConfiguration,
    org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+SHIFT+T,
    ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace,
        ,
        Category(org.eclipse.lsp4e.category,Language Servers,null,true),
        org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@425a5c2e,
        ,,true),null),
    org.eclipse.ui.defaultAcceleratorConfiguration,
    org.eclipse.ui.contexts.window,,,system)
Application started in : 8348ms

!ENTRY org.eclipse.ui.navigator 2 0 2021-07-13 13:05:43.592
!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering

!ENTRY org.eclipse.ui.navigator 2 0 2021-07-13 13:05:43.592
!MESSAGE Can't find Navigator Content Descriptor with id: org.eclipse.jst.servlet.ui.EnhancedJavaRendering
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Gdk-Message: 13:05:44.764: Eclipse: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

In those cases where the Eclipse window simply disappears rather than showing the window with command line arguments, the last lines are a bit different. I suspect this just a problem handling the error, however, rather than hinting at the cause:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[xcb] Unknown sequence number while awaiting reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
java: ../../src/xcb_io.c:295: poll_for_response: Assertion `!xcb_xlib_threads_sequence_lost' failed.
adangel commented 3 years ago

Good news, I finally could reproduce the problem: It only appears if X11 + GTK3 is used - I already use wayland and there the bug doesn't seem to be a problem.

To reproduce (for future reference):

export LANG=en_US.UTF-8
Xnest :99 &
metacity -d :99 &
DISPLAY=:99 xterm &

Then inside the xterm, force x11 and start eclipse:

export GDK_BACKEND=x11
eclipse/eclipse -consoleLog -data pmd-test

The problem appears, when PMD plugin is installed and PMD markers exist in the project. It is triggered by the RuleLabelDecorator which adds the violation icons to the project explorer view. Updating the labels is called in a separate thread which is not the UI thread, but apparently when painting off-screen images, it still needs to happen in the UI thread (at least for X11).

The problem manifests in different ways: Eclipse/Java simply might crash, sometimes you see the message

[xcb] Unknown sequence number while processing reply
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
java: ../../src/xcb_io.c:725: _XReply: Assertion `!xcb_xlib_threads_sequence_lost' failed.

sometimes not. Sometimes eclipse doesn't respond anymore (I guess a deadlock...). Sometimes it just works without a problem.

It is more often reproducible, if no editor view is open - the editor view also needs the violation markers, so when the rule label decorator is executed, the violation markers might already be initialized. So, close all editors and start eclipse again. Usually it crashes then.

Workaround: As this problem occurs due to the rule label decorator decorating the projects at start up: if you disable this decorator, eclipse won't crash: Window -> Preferences: General/Appearance/Label Decorations: Rule Violation Decorator . You might also directly modify the preferences storage directly if you can't get eclipse up: In .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs set ENABLED_DECORATORS=net.sourceforge.pmd.eclipse.plugin.RuleLabelDecorator\:false.

Background Info: