Bug 1285356 - [gtk3] gtk2 Swing/AWT GUIs in java-based extensions crash gtk3 libreoffice
Summary: [gtk3] gtk2 Swing/AWT GUIs in java-based extensions crash gtk3 libreoffice
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: libreoffice
Version: 23
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Caolan McNamara
QA Contact: Fedora Extras Quality Assurance
URL: https://retrace.fedoraproject.org/faf...
Whiteboard: abrt_hash:254d4627532035d697583e85c45...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-11-25 12:59 UTC by Christian Stadelmann
Modified: 2016-02-23 01:23 UTC (History)
6 users (show)

Fixed In Version: libreoffice-5.0.5.2-2.fc23
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-02-23 01:23:42 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
File: backtrace (177.54 KB, text/plain)
2015-11-25 12:59 UTC, Christian Stadelmann
no flags Details
File: core_backtrace (58.64 KB, text/plain)
2015-11-25 12:59 UTC, Christian Stadelmann
no flags Details
File: dso_list (28.69 KB, text/plain)
2015-11-25 12:59 UTC, Christian Stadelmann
no flags Details
File: limits (1.29 KB, text/plain)
2015-11-25 12:59 UTC, Christian Stadelmann
no flags Details
File: maps (135.85 KB, text/plain)
2015-11-25 12:59 UTC, Christian Stadelmann
no flags Details
File: namespaces (85 bytes, text/plain)
2015-11-25 12:59 UTC, Christian Stadelmann
no flags Details
File: open_fds (9.02 KB, text/plain)
2015-11-25 12:59 UTC, Christian Stadelmann
no flags Details
File: proc_pid_status (1.00 KB, text/plain)
2015-11-25 12:59 UTC, Christian Stadelmann
no flags Details

Description Christian Stadelmann 2015-11-25 12:59:21 UTC
Description of problem:
I started libreoffice-gtk3 with a java-based extension (LanguageTool, see https://languagetool.org/ ). When I tried to open the extensions' GUI from menu ("Tools" → "LanguageTool" → "Options…") libreoffice crashed.
This crash is expected since
1. libreoffice uses gtk3
2. libreoffice runs java in its own process
3. java builds GUIs based on AWT or Swing based on gtk2
4. gtk2 and gtk3 libraries must not be loaded into the same process

Looks like libreoffice needs to
a) disable AWT/Swing GUIs for extensions
b) keep using gtk2 until java is ported to gtk3 or at least away from gtk2
c) put extensions or java code in a separate subprocess like firefox does with its plugins

Version-Release number of selected component:
libreoffice-core-5.0.3.2-4.fc23

Additional info:
reporter:       libreport-2.6.3
backtrace_rating: 4
cmdline:        /usr/lib64/libreoffice/program/soffice.bin --splash-pipe=5
crash_function: CallSystemHandler(int)
executable:     /usr/lib64/libreoffice/program/soffice.bin
kernel:         4.2.6-300.fc23.x86_64
runlevel:       N 5
type:           CCpp

Truncated backtrace:
Thread no. 1 (2 frames)
 #2 CallSystemHandler(int) at /usr/src/debug/libreoffice-5.0.3.2/sal/osl/unx/signal.cxx:367
 #3 SignalHandlerFunction(int) at /usr/src/debug/libreoffice-5.0.3.2/sal/osl/unx/signal.cxx:452

Comment 1 Christian Stadelmann 2015-11-25 12:59:28 UTC
Created attachment 1098799 [details]
File: backtrace

Comment 2 Christian Stadelmann 2015-11-25 12:59:30 UTC
Created attachment 1098800 [details]
File: core_backtrace

Comment 3 Christian Stadelmann 2015-11-25 12:59:32 UTC
Created attachment 1098801 [details]
File: dso_list

Comment 4 Christian Stadelmann 2015-11-25 12:59:33 UTC
Created attachment 1098802 [details]
File: limits

Comment 5 Christian Stadelmann 2015-11-25 12:59:36 UTC
Created attachment 1098803 [details]
File: maps

Comment 6 Christian Stadelmann 2015-11-25 12:59:38 UTC
Created attachment 1098804 [details]
File: namespaces

Comment 7 Christian Stadelmann 2015-11-25 12:59:40 UTC
Created attachment 1098805 [details]
File: open_fds

Comment 8 Christian Stadelmann 2015-11-25 12:59:41 UTC
Created attachment 1098806 [details]
File: proc_pid_status

Comment 9 Caolan McNamara 2015-12-01 11:47:48 UTC
caolanm->ahughes: longer term do we expect the swing/awt stuff to be implemented via gtk3 ?

caolanm->sbergman: shorter term any ideas about how to detect/head-off this problem ?

Comment 10 Andrew John Hughes 2015-12-04 23:37:16 UTC
It's been talked about a couple of times in the past, but it always seems to diverge into the idea of a long-term project that would replace rather than update the existing one. One was even attempted as part of Google's Summer of Code, but I see no sign of it being integrated.

I would like to look at just getting it to build against Gtk+ 3 as a start, even if it's not optimal on that version. Would this solve your problem?

You can turn Gtk+ off by setting a different default look and feel. Maybe it should not even be the default on GNOME 3? Oddly, it's not the default on other Gtk+ desktops like Xfce. There's another long-standing bug for that.

Comment 11 Christian Stadelmann 2015-12-06 22:29:34 UTC
I think either ahughes or me is missing the point here.

(In reply to Andrew John Hughes from comment #10)
> I would like to look at just getting it to build against Gtk+ 3 as a start, even if it's not optimal on that version. Would this solve your problem?

It already does build. The issue is that at runtime libreoffice loads java (JVM + standard library) which can load GUI code using Swing based on Gtk2. If libreoffice is started with a Gtk3 backend both Gtk2 and Gtk3 code would reside in the same process, which is disallowed and will always crash.

> You can turn Gtk+ off by setting a different default look and feel.

How would you be able to do that? Afaik all (Java+)Swing LookAndFeels are implemented using Gtk3. For example LanguageTool (the extension mentioned above) is using the Nimbus LookAndFeel and crashes anyway.

Comment 12 Michael Stahl 2015-12-07 12:02:10 UTC
a workaround is to set SAL_USE_VCLPLUGIN=gtk (to use gtk2 plugin) or SAL_USE_VCLPLUGIN=gen (to use generic X11 plugin) in the environment for LibreOffice.

does the JRE have a similar architecture with different back-ends for the UI?  would it be possible to select a non-gtk2 plugin with an environment variable or command line paramater?

Comment 13 Christian Stadelmann 2015-12-07 16:24:00 UTC
(In reply to Christian Stadelmann from comment #11)
> > You can turn Gtk+ off by setting a different default look and feel.
> 
> How would you be able to do that? Afaik all (Java+)Swing LookAndFeels are
> implemented using Gtk3. For example LanguageTool (the extension mentioned
> above) is using the Nimbus LookAndFeel and crashes anyway.

I meant Gtk2, sorry. Java is based on Gtk2 on Linux.

And it looks like there has been some work to port Swing/AWT to gtk3 but it has not been merged upstream.

Comment 14 Andrew John Hughes 2015-12-08 02:20:30 UTC
(In reply to Christian Stadelmann from comment #11)
> I think either ahughes or me is missing the point here.
> 
> (In reply to Andrew John Hughes from comment #10)
> > I would like to look at just getting it to build against Gtk+ 3 as a start, even if it's not optimal on that version. Would this solve your problem?
> 
> It already does build. The issue is that at runtime libreoffice loads java
> (JVM + standard library) which can load GUI code using Swing based on Gtk2.
> If libreoffice is started with a Gtk3 backend both Gtk2 and Gtk3 code would
> reside in the same process, which is disallowed and will always crash.
> 

I'm referring to OpenJDK and porting its Gtk+ 2 look and feel to Gtk+ 3.

> > You can turn Gtk+ off by setting a different default look and feel.
> 
> How would you be able to do that? Afaik all (Java+)Swing LookAndFeels are
> implemented using Gtk3. For example LanguageTool (the extension mentioned
> above) is using the Nimbus LookAndFeel and crashes anyway.

Nothing in OpenJDK is based on Gtk 3. The Gtk+ look and feel uses Gtk+ 2. The rest are a mix of X and native Java.

AIUI, it would be enough for one piece of Java code in the process to load Gtk+ 2 to cause the issue.

Comment 15 Caolan McNamara 2016-02-17 16:15:26 UTC
I have a bodge for this on our side to disable swing using gtk2 if we are using gtk3

Comment 16 Christian Stadelmann 2016-02-17 16:29:50 UTC
What does that mean? will gtk2 UIs be blocked? Or will swing stop using gtk2?

Comment 17 Andrew John Hughes 2016-02-17 17:00:41 UTC
It's possible to use Swing without Gtk+ at all. It's just used for an optional look and feel (i.e. to make the widgets look like Gtk+ widgets rather than Java widgets).

Caolan, can you share this 'bodge'? Off-hand, I think just avoiding the system look and feel should be enough, but, if not, that's something we can look at in OpenJDK.

Comment 18 Caolan McNamara 2016-02-17 20:59:32 UTC
Yeah, I'm just trying to force swing not to use gtk2 if it gets asked to use the SystemLookAndFeel when launched from a gtk3-using LibreOffice

i.e. -Dswing.systemlaf=something_or_other

https://gerrit.libreoffice.org/#/c/22433/2/stoc/source/javavm/javavm.cxx

caolanm->ahughes: It's not LibreOffice that uses swing, it's random java extensions that are launched from LibreOffice via the Java VM integration that might or might not attempt to use the native look.

Perhaps it would work on the openjdk side to dlsym(NULL, "gtk_widget_get_path") or some other gtk3-only symbol to detect if its unsafe to try and load any gtk2 libs.

Comment 19 Christian Stadelmann 2016-02-17 21:50:14 UTC
Since this issue can also happen in eclipse (SWT is based on Gtk+ 3 too) a solution in openjdk would be useful.

Comment 20 Andrew John Hughes 2016-02-18 01:00:27 UTC
(In reply to Caolan McNamara from comment #18)
> Yeah, I'm just trying to force swing not to use gtk2 if it gets asked to use
> the SystemLookAndFeel when launched from a gtk3-using LibreOffice
> 
> i.e. -Dswing.systemlaf=something_or_other
> 
> https://gerrit.libreoffice.org/#/c/22433/2/stoc/source/javavm/javavm.cxx
> 
> caolanm->ahughes: It's not LibreOffice that uses swing, it's random java
> extensions that are launched from LibreOffice via the Java VM integration
> that might or might not attempt to use the native look.
> 

Ah, I see.

> Perhaps it would work on the openjdk side to dlsym(NULL,
> "gtk_widget_get_path") or some other gtk3-only symbol to detect if its
> unsafe to try and load any gtk2 libs.

That's a good test. I look at getting it into OpenJDK.

Comment 21 Fedora Update System 2016-02-18 14:25:32 UTC
libreoffice-5.0.5.2-2.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-ad89a358ff

Comment 22 Fedora Update System 2016-02-21 17:59:50 UTC
libreoffice-5.0.5.2-2.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-ad89a358ff

Comment 23 Fedora Update System 2016-02-23 01:23:39 UTC
libreoffice-5.0.5.2-2.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.