Bug 548806 - [GTK][LXDE] SIGSEGV in Java_org_eclipse_swt_internal_C_strlen
Summary: [GTK][LXDE] SIGSEGV in Java_org_eclipse_swt_internal_C_strlen
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.12   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Alexandr Miloslavskiy CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-06-30 10:07 EDT by Jens Lideström CLA
Modified: 2019-07-04 13:57 EDT (History)
3 users (show)

See Also:


Attachments
VM crash report file (207.59 KB, text/x-log)
2019-06-30 10:07 EDT, Jens Lideström CLA
no flags Details
Eclipse log file (7.09 KB, text/plain)
2019-06-30 10:08 EDT, Jens Lideström CLA
no flags Details
Lubuntu dialog for D-Bus Gnome setting (44.97 KB, image/png)
2019-07-02 14:03 EDT, Jens Lideström CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Lideström CLA 2019-06-30 10:07:32 EDT
Created attachment 279129 [details]
VM crash report file

I get a SIGSEGV in Java_org_eclipse_swt_internal_C_strlen on startup. The crash happens a while after the splash screen shows, before a progress bar appears on the splash.

The previous Eclipse version, 2019-03 works fine on my system.

I have attached the VM crash report and the Eclipse log file to this ticket.

### Relevant software 

Eclipse version:
Eclipse IDE for Java Developers Linux 64-bit 2019-6
https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2019-06/R/eclipse-java-2019-06-R-linux-gtk-x86_64.tar.gz

Latest working Eclipse release:
Eclipse IDE for Java Developers Linux 64-bit 2019-3
https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2019-03/R/eclipse-java-2019-03-R-linux-gtk-x86_64.tar.gz

OS: Lubuntu 18.04.2 LTS 64-bit
$ uname -a
Linux XXX-box 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

GTK versions:
$  dpkg -l libgtk2.0-0 libgtk-3-0
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name              Version           Arch 
+++-=================-=================-=====
ii  libgtk-3-0:amd64  3.22.30-1ubuntu3  amd64
ii  libgtk2.0-0:amd64 2.24.32-1ubuntu1  amd64

Java version:
$ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)

I get the same crash with the following JRE:
$ /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)
Comment 1 Jens Lideström CLA 2019-06-30 10:08:05 EDT
Created attachment 279130 [details]
Eclipse log file
Comment 2 Andrey Loskutov CLA 2019-06-30 10:21:29 EDT
C  [libswt-gtk-4926r21.so+0x36ec8]  Java_org_eclipse_swt_internal_C_strlen+0xf
j  org.eclipse.swt.internal.Converter.cCharPtrToJavaString(JZ)Ljava/lang/String;+1
j  org.eclipse.swt.internal.SessionManagerDBus.extractVariantTupleS(J)Ljava/lang/String;+16
j  org.eclipse.swt.internal.SessionManagerDBus.registerClient(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;+64
j  org.eclipse.swt.internal.SessionManagerDBus.registerClient()Z+57
j  org.eclipse.swt.internal.SessionManagerDBus.start()Z+8
j  org.eclipse.swt.internal.SessionManagerDBus.<init>()V+57
j  org.eclipse.swt.widgets.Display.initializeSessionManager()V+5
j  org.eclipse.swt.widgets.Display.init()V+29
j  org.eclipse.swt.graphics.Device.<init>(Lorg/eclipse/swt/graphics/DeviceData;)V+172
j  org.eclipse.swt.widgets.Display.<init>(Lorg/eclipse/swt/graphics/DeviceData;)V+2
j  org.eclipse.swt.widgets.Display.<init>()V+2
j  org.eclipse.ui.internal.Workbench.createDisplay()Lorg/eclipse/swt/widgets/Display;+81
j  org.eclipse.ui.PlatformUI.createDisplay()Lorg/eclipse/swt/widgets/Display;+0
Comment 3 Andrey Loskutov CLA 2019-06-30 10:23:34 EDT
Probably side effect from bug 531634. Alexander, could you please investigate?
Comment 4 Jens Lideström CLA 2019-06-30 14:26:24 EDT
Since bug 531634 and frames in the stack trace are related to D-Bus, here is my D-Bus version:

$ dpkg -l dbus
||/ Name  Version            Arch  
+++-=====-==================-======
ii  dbus  1.12.2-1ubuntu1.1  amd64
Comment 5 Jens Lideström CLA 2019-06-30 15:35:57 EDT
I think the following is related to the problem.

I noted that in SessionManagerDBus there is code for D-Bus session managers with two names, org.gnome.SessionManager and org.xfce.SessionManager. [1]

On Lubuntu, where the LXDE desktop is used, the following D-Bus interface is used for the session manager: org.lxde.SessionManager [2]

[1]: https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java#n391

[2]: https://wiki.lxde.org/en/LXSession
Comment 6 Jens Lideström CLA 2019-06-30 15:44:57 EDT
Using the following launcher argument works around the issue and lets me start Eclipse:

eclipse -vmargs -Dorg.eclipse.swt.internal.SessionManagerDBus.disable

Information:
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java#n113
Comment 7 Alexandr Miloslavskiy CLA 2019-07-01 13:26:24 EDT
I have installed a fresh LUbuntu 19.04 and 'SessionManagerDBus' works as expected:
* It detects that Gnome is not present
* It detects that XFCE is not present
* It gives up and doesn't start, so 'registerClient' (where it crashes for you) is not called.

Going to test 18.04 tomorrow. I have no idea why it gets into 'registerClient' for you. If you can debug and see what happens, please do.
Comment 8 Alexandr Miloslavskiy CLA 2019-07-01 14:04:10 EDT
I have now installed and tested fresh LUbuntu 18.04, works exactly the same as 19.04.

$ uname -a
4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Then, I have installed all OS updates.

$ uname -a
4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Also no problems here.

$ dpkg -l libgtk2.0-0 libgtk-3-0
ii  libgtk-3-0:amd64  3.22.30-1ubuntu3  amd64
ii  libgtk2.0-0:amd64 2.24.32-1ubuntu1  amd64

$ dpkg -l dbus
ii  dbus  1.12.2-1ubuntu1.1  amd64

Did you by chance also install Gnome or XFCE?
Comment 9 Jens Lideström CLA 2019-07-01 15:19:44 EDT
(In reply to Alexandr Miloslavskiy from comment #8)
> Also no problems here.

Weird!

> Did you by chance also install Gnome or XFCE?

No. Just the standard LXDE desktop.
Comment 10 Alexandr Miloslavskiy CLA 2019-07-02 04:04:45 EDT
Let's find out who implements this broken DBus service.

$ dbus-send --session --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID string:org.gnome.SessionManager

$ dbus-send --session --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID string:org.xfce.SessionManager

For me, as expected, both report error 'org.freedesktop.DBus.Error.NameHasNoOwner'.

For you however one of these will return PID of the process that implements service.
Then run `ps u --pid 1550` with your PID and let me know which process is that.
Comment 11 Jens Lideström CLA 2019-07-02 14:03:16 EDT
Created attachment 279156 [details]
Lubuntu dialog for D-Bus Gnome setting
Comment 12 Jens Lideström CLA 2019-07-02 14:11:58 EDT
Aha!

Lubuntu has a little checkbox in the LXSession configuration dialog for "Dbus Gnome". (See attached screen shot.)

If that checkbox is selected then the error occurs.

I don't know what the checkbox does. Did I check it? I don't know.

(In reply to Alexandr Miloslavskiy from comment #10)
> Let's find out who implements this broken DBus service.

Let's!

> $ dbus-send --session --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID string:org.gnome.SessionManager

If the checkbox "Dbus Gnome" is selected then the result is the following:

method return time=1562089141.181879 sender=org.freedesktop.DBus -> destination=:1.48 serial=3 reply_serial=2
   uint32 836

If the checkbox is *not* selected the result is this:

Error org.freedesktop.DBus.Error.NameHasNoOwner: Could not get PID of name 'org.gnome.SessionManager': no such name

> $ dbus-send --session --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID string:org.xfce.SessionManager

Error org.freedesktop.DBus.Error.NameHasNoOwner: Could not get PID of name 'org.xfce.SessionManager': no such name

> 
> For me, as expected, both report error
> 'org.freedesktop.DBus.Error.NameHasNoOwner'.
> 
> For you however one of these will return PID of the process that implements service.
> Then run `ps u --pid 1550` with your PID and let me know which process is that.

$ ps u --pid 836
/usr/bin/lxsession -s Lubuntu -e LXDE

Of course, even if Lubuntu has an error or my system is misconfigured, the platform shouldn't crash like this.
Comment 13 Alexandr Miloslavskiy CLA 2019-07-03 13:30:31 EDT
Thanks a lot for additional infos!
Sorry for the delay, was too busy with other stuff today.
I expect to debug it tomorrow.
Comment 14 Alexandr Miloslavskiy CLA 2019-07-04 10:13:14 EDT
The reason for this is a bug in LXDE's fake Gnome service.

See [1] line 65: Body of 'RegisterClient' is basically empty, while it must do one of:
1) If success, return a variant in (o) format, that is a tuple containing a string
2) If error, provide the error object.

But it doesn't do both, so it looks like success, but the returned value is invalid.
I can only call it an evil trap.

On top of that, in LUbuntu 19.04 they abandoned LXDE in favor of LXQT, which doesn't seem to have the Gnome emulation anymore.
Also, default LUbuntu 18.04 doesn't have the evil Gnome emulation enabled.

So I'm not sure if fix is needed. @Eric, what's your stance?

[1] https://github.com/lxde/lxsession/blob/master/lxsession/dbus-gnome-session.vala
Comment 15 Eric Williams CLA 2019-07-04 10:30:34 EDT
(In reply to Alexandr Miloslavskiy from comment #14)
> The reason for this is a bug in LXDE's fake Gnome service.
> 
> See [1] line 65: Body of 'RegisterClient' is basically empty, while it must
> do one of:
> 1) If success, return a variant in (o) format, that is a tuple containing a
> string
> 2) If error, provide the error object.
> 
> But it doesn't do both, so it looks like success, but the returned value is
> invalid.
> I can only call it an evil trap.
> 
> On top of that, in LUbuntu 19.04 they abandoned LXDE in favor of LXQT, which
> doesn't seem to have the Gnome emulation anymore.
> Also, default LUbuntu 18.04 doesn't have the evil Gnome emulation enabled.
> 
> So I'm not sure if fix is needed. @Eric, what's your stance?
> 
> [1]
> https://github.com/lxde/lxsession/blob/master/lxsession/dbus-gnome-session.
> vala

If LUbuntu 18.04 doesn't have it enabled, then no fix in SWT is needed -- older Ubuntu versions aren't supported target environments for SWT.

Even if we wanted to fix this, could we? Not much to be done if garbage input is being fed to us without an error being raised.
Comment 16 Eclipse Genie CLA 2019-07-04 10:52:53 EDT
New Gerrit change created: https://git.eclipse.org/r/145480
Comment 17 Alexandr Miloslavskiy CLA 2019-07-04 10:55:24 EDT
The patch appears to be simple enough. After internal discussion we decided that if our software can avoid the crash, it should try to do so. This is the patch we're going to use.
Comment 18 Jens Lideström CLA 2019-07-04 12:38:31 EDT
Great that you found the cause! Thanks for the investigation!

I really think that this should be fixed. Also, I think it would be a good idea to review the code for similar problems and fix them as far as possible.

The platform really shouldn't crash if it gets invalid input from external applications.
Comment 19 Alexandr Miloslavskiy CLA 2019-07-04 13:19:15 EDT
Thanks for your high-quality input!
Comment 21 Eric Williams CLA 2019-07-04 13:57:31 EDT
(In reply to Eclipse Genie from comment #20)
> Gerrit change https://git.eclipse.org/r/145480 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=29744c3324413c8033adbd500c84ae08d6a211fb

In master now.