Bug 1667675

Summary: The program 'java' received an X Window System error
Product: [Fedora] Fedora Reporter: Gabriele Pohl <contact>
Component: openjfxAssignee: Nicolas De Amicis <deamicis>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 29CC: ahughes, contact, dbhole, deamicis, hegjon, jerboaa, jvanek, mat.booth, msrb, mvala, omajid, sgehwolf
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: openjfx-8.0.202-5.b07.fc28 openjfx-8.0.202-5.b07.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-02-19 05:53:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gabriele Pohl 2019-01-19 17:38:49 UTC
Description of problem:

Java application MediathekView crashes with the following error message:

(java:19836): Gdk-ERROR **: 17:23:02.343: The program 'java' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
  (Details: serial 10905 error_code 3 request_code 20 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
./mediathek-start.sh: line 1: 19836 Trace/breakpoint trap   (core dumped) java -jar MediathekView.jar


Version-Release number of selected component (if applicable):

  java-1.8.0-openjdk-1:1.8.0.191.b13-0.fc29.x86_64                              
  java-1.8.0-openjdk-headless-1:1.8.0.191.b13-0.fc29.x86_64                     
  java-1.8.0-openjdk-openjfx-1:1.8.0.191.b13-0.fc29.x86_64   

How reproducible:


Steps to Reproduce:
1. Get java application MediathekView from here: https://mediathekview.de/download/

2. Run the app with "java -jar MediathekView.jar"

3. Try to download a video file and choose the directory where to save it. After that the application crashes

Actual results:

Stable versions of MediathekView are not usable with Fedora components

Expected results: No crashes


Additional info:

I informed the MediathekView developers at github about the issue:
https://github.com/mediathekview/MediathekView/issues/405

Comment from another fedora bugreport:

https://bugzilla.redhat.com/show_bug.cgi?id=1657636

"For the segfaults with MediathekView, please fill a new bug report. I'm investigating on that and it seems that is libglassgtk2.so the source of the problem. There is a bug when JavaFX and Swing are mixed, I see also these segfaults with javafx apps launched with icedtea-web (javaws)"

Comment 1 Severin Gehwolf 2019-01-21 09:50:51 UTC
(In reply to Gabriele Pohl from comment #0)
> Additional info:
> 
> I informed the MediathekView developers at github about the issue:
> https://github.com/mediathekview/MediathekView/issues/405
> 
> Comment from another fedora bugreport:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1657636
> 
> "For the segfaults with MediathekView, please fill a new bug report. I'm
> investigating on that and it seems that is libglassgtk2.so the source of the
> problem. There is a bug when JavaFX and Swing are mixed, I see also these
> segfaults with javafx apps launched with icedtea-web (javaws)"

Based on those comments this seems an OpenJFX 8 issue. Re-assigning component.

Comment 2 Nicolas De Amicis 2019-01-21 15:05:00 UTC
I prepare a new build 8.0.202b07 for the package openjfx which introduces the official support of GTK3 (adding libglassgtk3.so). I'm testing MediathekView with this build.
If I run the app with java -jar MediathekView.jar the app crashes.
The detailed dump is 
Program terminated with signal SIGTRAP, Trace/breakpoint trap.
#0  0x00007fb231fcc1e5 in _g_log_abort (breakpoint=1) at gmessages.c:554
554	    G_BREAKPOINT ();
[Current thread is 1 (Thread 0x7fb23cba4700 (LWP 28373))]
(gdb) bt
#0  0x00007fb231fcc1e5 in _g_log_abort (breakpoint=1) at gmessages.c:554
#1  0x00007fb231fcd2b1 in g_log_default_handler
    (log_domain=log_domain@entry=0x7fb2324f8106 "Gdk", log_level=log_level@entry=6, message=message@entry=0x7fb1e4028690 "The program 'java' received an X Window System error.\nThis probably reflects a bug in the program.\nThe error was 'BadWindow (invalid Window parameter)'.\n  (Details: serial 34069 error_code 3 request_c"..., unused_data=unused_data@entry=0x0) at gmessages.c:3111
#2  0x00007fb231fcd4ff in g_logv (log_domain=0x7fb2324f8106 "Gdk", log_level=G_LOG_LEVEL_ERROR, format=<optimized out>, args=args@entry=0x7fb23cba2f90) at gmessages.c:1350
#3  0x00007fb231fcd6f3 in g_log (log_domain=log_domain@entry=0x7fb2324f8106 "Gdk", log_level=log_level@entry=G_LOG_LEVEL_ERROR, format=format@entry=0x7fb232516d14 "%s") at gmessages.c:1413
#4  0x00007fb2324e048d in gdk_x_error (display=<optimized out>, error=<optimized out>) at gdkmain-x11.c:486
#5  0x00007fb23d801402 in _XError (dpy=dpy@entry=0x7fb254721f60, rep=rep@entry=0x7fb1e4008cb0) at XlibInt.c:1444
#6  0x00007fb23d7fe297 in handle_error (dpy=dpy@entry=0x7fb254721f60, err=0x7fb1e4008cb0, in_XReply=in_XReply@entry=1) at xcb_io.c:199
#7  0x00007fb23d7ff493 in _XReply (dpy=dpy@entry=0x7fb254721f60, rep=rep@entry=0x7fb23cba32b0, extra=extra@entry=0, discard=discard@entry=0) at xcb_io.c:708
#8  0x00007fb23d7e4c39 in XGetWindowProperty
    (dpy=0x7fb254721f60, w=73400630, property=508, offset=0, length=1, delete=0, req_type=0, actual_type=0x7fb1dc55e260, actual_format=0x7fb1dc468600, nitems=0x7fb1e4003800, bytesafter=0x7fb1e4008630, prop=0x7fb1e40035a0) at GetProp.c:69
#9  0x00007fb24540c206 in  ()
#10 0x0000000000000000 in  ()

I'm not an expert with gdb, but I think there is an inappropriate argument passed to the function XGetWindowProperty?

If I try to start with the new vm args: java -Djdk.gtk.verbose=true -Djdk.gtk.version=3 -jar MediathekView.jar, the application works well on GTK3, that's why I think it's a gtk2 or libglassgtk2.so bug.

I made a last test with the official Oracle jdk8u202 and the application run correctly but if I replace the libglassgtk2.so from Oracle with that of Fedora libglassgtk2.so the application crashes.

I don't see anything that could cause a problem in our patch files

Comment 3 Mat Booth 2019-01-21 15:23:09 UTC
Gabriele, does Nicolas' solution work for you?

I.e.:

$ java -Djdk.gtk.verbose=true -Djdk.gtk.version=3 -jar MediathekView.jar

If so I propose that you contact the MediathekView people and letting them know -- perhaps they can update their documentation or even change their product to try GTK3 first and use it if available. Everything should be using GTK3 by default these days anyway IMO.

Comment 4 Gabriele Pohl 2019-01-21 18:13:26 UTC
Mat, Nicolas' solution is based on a new build of openjfx..

I don't have this component therefore it's not a solution for my Fedora 29 standard distribution as libglassgtk3 is missing there:

$ java -Djdk.gtk.verbose=true -Djdk.gtk.version=3 -jar MediathekView.jar

...

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b13-0.fc29.x86_64/jre/lib/amd64/libglassgtk3.so
	at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:267)
	at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
	at javafx.embed.swing.JFXPanel.lambda$initFx$2(JFXPanel.java:232)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b13-0.fc29.x86_64/jre/lib/amd64/libglassgtk3.so
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1827)
	at java.lang.Runtime.load0(Runtime.java:809)
	at java.lang.System.load(System.java:1086)
	at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoader.java:201)
	at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:94)
	at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:39)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$new$5(GtkApplication.java:156)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:140)
	at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
	at com.sun.glass.ui.Application.run(Application.java:146)
	at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
	... 3 more

I am willing to test when you instruct me how to get the needed environment.

Comment 5 Nicolas De Amicis 2019-01-29 10:01:32 UTC
I made some other tests and it appears that if I compile openjfx with the (current) gradle.properties, in "DebugNative", I have a crash with libglassgtk2.so:
cat > gradle.properties << EOF
COMPILE_WEBKIT = false
COMPILE_MEDIA = false
BUILD_JAVADOC = true
BUILD_SRC_ZIP = true
GRADLE_VERSION_CHECK = false
CONF = DebugNative
EOF

but, if I compile in "Debug" or "Release", I have no problem with libglassgtk2.so:
COMPILE_WEBKIT = false
COMPILE_MEDIA = false
BUILD_JAVADOC = true
BUILD_SRC_ZIP = true
GRADLE_VERSION_CHECK = false
CONF = Release
EOF

I don't understand the link between that, I still analyzing the gradle script.

Comment 6 Nicolas De Amicis 2019-02-04 10:54:59 UTC
I found the problem!
It's located in modules/graphics/src/main/native-glass/gtk/GlassApplication.cpp at line 189:
The flag VERBOSE is defined in Debug or DebugNative, the function gdk_error_trap_push will be called and then we have our X error.
...
    // GTK installs its own X error handler that conflicts with AWT.
    // During drag and drop, AWT hides errors so we need to hide them
    // to avoid exit()'ing.  It's not clear that we don't want to hide
    // X error all the time, otherwise FX will exit().
    //
    // A better solution would be to coordinate with AWT and save and
    // restore the X handler.

    // Disable X error handling
#ifndef VERBOSE
    if (!noErrorTrap) {
        gdk_error_trap_push();
    }
#endif
    gtk_main();
...

The problem was reported to openjdk (in jdk 7) with these bugs: RT-21408 and RT-20756. The comment in relation is "When the last JFrame closes and DISPOSE_ON_CLOSE is specified, Java exits with an X error. X error are hidden during the FX event loop and should be restored when the event loop exits. Unfortunately, this is too early. The fix is to never restore X errors."

I will prepare a new build for correcting this issue but I'm waiting on the next release of openjdk-1.8.0 for adding the new symlink on libglassgtk3.so

Comment 7 Nicolas De Amicis 2019-02-05 12:11:08 UTC
Feel free to test the CI build https://koji.fedoraproject.org/koji/buildinfo?buildID=1205926

Comment 8 Gabriele Pohl 2019-02-05 12:28:27 UTC
Great! Nicolas :)
It works with the new version.

Thanks a lot!

Comment 9 Mat Booth 2019-02-05 13:24:54 UTC
Thanks for the work you are doing on keeping this package in good condition, Nicolas :-)

Comment 10 Fedora Update System 2019-02-06 07:37:25 UTC
openjfx-8.0.202-5.b07.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-9a53d59e9f

Comment 11 Fedora Update System 2019-02-06 07:39:27 UTC
openjfx-8.0.202-5.b07.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2019-475ba1ff79

Comment 12 Fedora Update System 2019-02-10 01:50:25 UTC
openjfx-8.0.202-5.b07.fc28 has been pushed to the Fedora 28 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-2019-475ba1ff79

Comment 13 Fedora Update System 2019-02-10 04:27:22 UTC
openjfx-8.0.202-5.b07.fc29 has been pushed to the Fedora 29 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-2019-9a53d59e9f

Comment 14 Fedora Update System 2019-02-19 05:53:37 UTC
openjfx-8.0.202-5.b07.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 15 Fedora Update System 2019-02-19 06:48:07 UTC
openjfx-8.0.202-5.b07.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2019-02-19 14:01:14 UTC
openjfx-8.0.202-5.b07.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.