JDK-8344102 : [Linux] Crash if control with InputMethodEvents enabled request focus too soon
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: jfx23.0.1,jfx24
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • Submitted: 2024-11-13
  • Updated: 2025-03-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
jfx25Unresolved
Related Reports
Relates :  
Description
On Linux, if for some reason a control with InputMethodEvents enabled takes the focus too soon, before the application is shown, there is a crash:

(java:34229): Gdk-CRITICAL **: 11:48:19.249: gdk_window_get_display: assertion 'GDK_IS_WINDOW (window)' failed

(java:34229): Gdk-CRITICAL **: 11:48:19.249: gdk_x11_display_get_xdisplay: assertion 'GDK_IS_DISPLAY (display)' failed
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f14985fca5d, pid=34229, tid=34269
#
# JRE version: OpenJDK Runtime Environment (23.0.1+11) (build 23.0.1+11-39)
# Java VM: OpenJDK 64-Bit Server VM (23.0.1+11-39, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libgdk-3.so.0+0x85a5d]  gdk_x11_window_get_xid+0xd

The attached test contains a very simple control implementation with InputMethodEvents enabled that can be used to reproduce the issue.

Steps: run the application on Linux with a recent JDK 21 or later, and JavaFX 23.0.1 or later. It will crash immediately.

Current thread (0x00007f14c442da00):  JavaThread "JavaFX Application Thread"        [_thread_in_native, id=34269, stack(0x00007f14043b3000,0x00007f14044b3000) (1024K)]

Stack: [0x00007f14043b3000,0x00007f14044b3000],  sp=0x00007f14044afe90,  free space=1011k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libgdk-3.so.0+0x85a5d]  gdk_x11_window_get_xid+0xd
j  com.sun.glass.ui.gtk.GtkView.enableInputMethodEventsImpl(JZ)V+0 javafx.graphics@23.0.1
j  com.sun.glass.ui.gtk.GtkView._enableInputMethodEvents(JZ)V+3 javafx.graphics@23.0.1
j  com.sun.glass.ui.View.enableInputMethodEvents(Z)V+13 javafx.graphics@23.0.1
j  com.sun.javafx.tk.quantum.ViewScene.enableInputMethodEvents(Z)V+5 javafx.graphics@23.0.1
j  javafx.scene.Scene.enableInputMethodEvents(Z)V+12 javafx.graphics@23.0.1
j  javafx.scene.Scene$FocusOwnerProperty.invalidated()V+74 javafx.graphics@23.0.1
j  javafx.beans.property.ObjectPropertyBase.markInvalid()V+13 javafx.base@23.0.1
j  javafx.beans.property.ObjectPropertyBase.set(Ljava/lang/Object;)V+72 javafx.base@23.0.1
j  javafx.scene.Scene.setFocusOwner(Ljavafx/scene/Node;Z)V+67 javafx.graphics@23.0.1
j  javafx.scene.Scene.requestFocus(Ljavafx/scene/Node;Z)V+23 javafx.graphics@23.0.1
j  javafx.scene.Node.requestFocus()V+13 javafx.graphics@23.0.1
j  hellofx.IMETest$IMEControlSkin.<init>(Lhellofx/IMETest$IMEControl;)V+62
j  hellofx.IMETest$IMEControl.createDefaultSkin()Ljavafx/scene/control/Skin;+5
j  javafx.scene.control.Control.doProcessCSS()V+25 javafx.controls@23.0.1
j  javafx.scene.control.Control$1.doProcessCSS(Ljavafx/scene/Node;)V+4 javafx.controls@23.0.1
j  com.sun.javafx.scene.control.ControlHelper.processCSSImpl(Ljavafx/scene/Node;)V+4 javafx.controls@23.0.1
j  com.sun.javafx.scene.NodeHelper.processCSS(Ljavafx/scene/Node;)V+5 javafx.graphics@23.0.1
j  javafx.scene.Parent.doProcessCSS()V+121 javafx.graphics@23.0.1
j  javafx.scene.Parent$1.doProcessCSS(Ljavafx/scene/Node;)V+4 javafx.graphics@23.0.1
j  com.sun.javafx.scene.ParentHelper.processCSSImpl(Ljavafx/scene/Node;)V+4 javafx.graphics@23.0.1
j  com.sun.javafx.scene.NodeHelper.processCSS(Ljavafx/scene/Node;)V+5 javafx.graphics@23.0.1
j  javafx.scene.Node.processCSS()V+99 javafx.graphics@23.0.1
j  javafx.scene.Scene.doCSSPass()V+23 javafx.graphics@23.0.1
j  javafx.scene.Scene.preferredSize()V+6 javafx.graphics@23.0.1
j  javafx.scene.Scene$2.preferredSize(Ljavafx/scene/Scene;)V+1 javafx.graphics@23.0.1
j  com.sun.javafx.scene.SceneHelper.preferredSize(Ljavafx/scene/Scene;)V+4 javafx.graphics@23.0.1
j  javafx.stage.Window$12.invalidated()V+384 javafx.graphics@23.0.1
j  javafx.beans.property.BooleanPropertyBase.markInvalid()V+13 javafx.base@23.0.1
j  javafx.beans.property.BooleanPropertyBase.set(Z)V+72 javafx.base@23.0.1
j  javafx.stage.Window.setShowing(Z)V+11 javafx.graphics@23.0.1
j  javafx.stage.Window.show()V+2 javafx.graphics@23.0.1
j  javafx.stage.Stage.show()V+1 javafx.graphics@23.0.1
j  hellofx.IMETest.start(Ljavafx/stage/Stage;)V+51
j  com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Ljava/util/concurrent/atomic/AtomicBoolean;Ljavafx/application/Application;)V+20 javafx.graphics@23.0.1
j  com.sun.javafx.application.LauncherImpl$$Lambda+0x00007f144b092440.run()V+8 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Ljava/lang/Runnable;Ljava/util/concurrent/CountDownLatch;)V+1 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl$$Lambda+0x00007f144b08e000.run()V+8 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Ljava/lang/Runnable;)Ljava/lang/Void;+1 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl$$Lambda+0x00007f144b08f4c0.run()Ljava/lang/Object;+4 javafx.graphics@23.0.1
j  java.security.AccessController.executePrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/lang/Class;)Ljava/lang/Object;+29 java.base@23.0.1
j  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+13 java.base@23.0.1
j  com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Ljava/lang/Runnable;Ljava/security/AccessControlContext;)V+7 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl$$Lambda+0x00007f144b08e430.run()V+8 javafx.graphics@23.0.1
j  com.sun.glass.ui.InvokeLaterDispatcher$Future.run()V+4 javafx.graphics@23.0.1
v  ~StubRoutines::call_stub 0x00007f14b3d8ec86
V  [libjvm.so+0x8cfb5b]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x2db
V  [libjvm.so+0x97c860]  jni_invoke_nonstatic(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, JavaThread*) [clone .constprop.1]+0x1d0
V  [libjvm.so+0x980068]  jni_CallVoidMethodV+0xb8
C  [libglassgtk3.so+0x1dda1]  JNIEnv_::CallVoidMethod(_jobject*, _jmethodID*, ...)+0x81
C  [libglassgtk3.so+0x1ddfc]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.sun.glass.ui.gtk.GtkView.enableInputMethodEventsImpl(JZ)V+0 javafx.graphics@23.0.1
j  com.sun.glass.ui.gtk.GtkView._enableInputMethodEvents(JZ)V+3 javafx.graphics@23.0.1
j  com.sun.glass.ui.View.enableInputMethodEvents(Z)V+13 javafx.graphics@23.0.1
j  com.sun.javafx.tk.quantum.ViewScene.enableInputMethodEvents(Z)V+5 javafx.graphics@23.0.1
j  javafx.scene.Scene.enableInputMethodEvents(Z)V+12 javafx.graphics@23.0.1
j  javafx.scene.Scene$FocusOwnerProperty.invalidated()V+74 javafx.graphics@23.0.1
j  javafx.beans.property.ObjectPropertyBase.markInvalid()V+13 javafx.base@23.0.1
j  javafx.beans.property.ObjectPropertyBase.set(Ljava/lang/Object;)V+72 javafx.base@23.0.1
j  javafx.scene.Scene.setFocusOwner(Ljavafx/scene/Node;Z)V+67 javafx.graphics@23.0.1
j  javafx.scene.Scene.requestFocus(Ljavafx/scene/Node;Z)V+23 javafx.graphics@23.0.1
j  javafx.scene.Node.requestFocus()V+13 javafx.graphics@23.0.1
j  hellofx.IMETest$IMEControlSkin.<init>(Lhellofx/IMETest$IMEControl;)V+62
j  hellofx.IMETest$IMEControl.createDefaultSkin()Ljavafx/scene/control/Skin;+5
j  javafx.scene.control.Control.doProcessCSS()V+25 javafx.controls@23.0.1
j  javafx.scene.control.Control$1.doProcessCSS(Ljavafx/scene/Node;)V+4 javafx.controls@23.0.1
j  com.sun.javafx.scene.control.ControlHelper.processCSSImpl(Ljavafx/scene/Node;)V+4 javafx.controls@23.0.1
j  com.sun.javafx.scene.NodeHelper.processCSS(Ljavafx/scene/Node;)V+5 javafx.graphics@23.0.1
j  javafx.scene.Parent.doProcessCSS()V+121 javafx.graphics@23.0.1
j  javafx.scene.Parent$1.doProcessCSS(Ljavafx/scene/Node;)V+4 javafx.graphics@23.0.1
j  com.sun.javafx.scene.ParentHelper.processCSSImpl(Ljavafx/scene/Node;)V+4 javafx.graphics@23.0.1
j  com.sun.javafx.scene.NodeHelper.processCSS(Ljavafx/scene/Node;)V+5 javafx.graphics@23.0.1
j  javafx.scene.Node.processCSS()V+99 javafx.graphics@23.0.1
j  javafx.scene.Scene.doCSSPass()V+23 javafx.graphics@23.0.1
j  javafx.scene.Scene.preferredSize()V+6 javafx.graphics@23.0.1
j  javafx.scene.Scene$2.preferredSize(Ljavafx/scene/Scene;)V+1 javafx.graphics@23.0.1
j  com.sun.javafx.scene.SceneHelper.preferredSize(Ljavafx/scene/Scene;)V+4 javafx.graphics@23.0.1
j  javafx.stage.Window$12.invalidated()V+384 javafx.graphics@23.0.1
j  javafx.beans.property.BooleanPropertyBase.markInvalid()V+13 javafx.base@23.0.1
j  javafx.beans.property.BooleanPropertyBase.set(Z)V+72 javafx.base@23.0.1
j  javafx.stage.Window.setShowing(Z)V+11 javafx.graphics@23.0.1
j  javafx.stage.Window.show()V+2 javafx.graphics@23.0.1
j  javafx.stage.Stage.show()V+1 javafx.graphics@23.0.1
j  hellofx.IMETest.start(Ljavafx/stage/Stage;)V+51
j  com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Ljava/util/concurrent/atomic/AtomicBoolean;Ljavafx/application/Application;)V+20 javafx.graphics@23.0.1
j  com.sun.javafx.application.LauncherImpl$$Lambda+0x00007f144b092440.run()V+8 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Ljava/lang/Runnable;Ljava/util/concurrent/CountDownLatch;)V+1 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl$$Lambda+0x00007f144b08e000.run()V+8 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Ljava/lang/Runnable;)Ljava/lang/Void;+1 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl$$Lambda+0x00007f144b08f4c0.run()Ljava/lang/Object;+4 javafx.graphics@23.0.1
j  java.security.AccessController.executePrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/lang/Class;)Ljava/lang/Object;+29 java.base@23.0.1
j  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+13 java.base@23.0.1
j  com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Ljava/lang/Runnable;Ljava/security/AccessControlContext;)V+7 javafx.graphics@23.0.1
j  com.sun.javafx.application.PlatformImpl$$Lambda+0x00007f144b08e430.run()V+8 javafx.graphics@23.0.1
j  com.sun.glass.ui.InvokeLaterDispatcher$Future.run()V+4 javafx.graphics@23.0.1
v  ~StubRoutines::call_stub 0x00007f14b3d8ec86
j  com.sun.glass.ui.gtk.GtkApplication._runLoop(Ljava/lang/Runnable;Z)V+0 javafx.graphics@23.0.1
j  com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$10(Ljava/lang/Runnable;Z)V+7 javafx.graphics@23.0.1
j  com.sun.glass.ui.gtk.GtkApplication$$Lambda+0x00007f144b032bb8.run()V+12 javafx.graphics@23.0.1
j  java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V+5 java.base@23.0.1
j  java.lang.Thread.run()V+19 java.base@23.0.1
v  ~StubRoutines::call_stub 0x00007f14b3d8ec86



Comments
It does not crash for me, so it might be resolved on JDK-8305418
29-03-2025

The crash log points to com.sun.glass.ui.gtk.GtkView.enableInputMethodEventsImpl, that calls Java_com_sun_glass_ui_gtk_GtkView_enableInputMethodEventsImpl in GlassView.cpp, that calls WindowContextBase::enableOrResetIME() in glass_window_ime.cpp, where a valid gdk_window object is required: Display *display = gdk_x11_display_get_xdisplay(gdk_window_get_display(gdk_window)); The call to enableInputMethodEventsImpl comes in the first place from Scene$FocusOwnerProperty::invalidated. If the scene has a valid node as focus owner and valid IME handlers, it will trigger this call. In the test, because of the focus request when the control is created, this line is reached before the Window that contains the Scene is focused, and gdk_window is still null. In any case, while it might be a bad control design, the application shouldn't crash.
13-11-2024