JDK-8236680 : [Linux] Crash on exit when window with owned child window is closed
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8u60,9,10,openjfx11,openjfx14
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • CPU: x86_64
  • Submitted: 2020-01-06
  • Updated: 2020-02-15
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
tbdUnresolved
Related Reports
Relates :  
Description
Running the attached program will cause a crash on exit:

$ java GlassCrash
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
	at GlassCrash$SizingTestApp.lambda$getTestDialog$2(GlassCrash.java:134)
	at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
	at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
	at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
	at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
	at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
	at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
	at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
	at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
	at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
	at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
	at javafx.graphics/javafx.stage.Window.fireEvent(Window.java:1368)
	at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1127)
	at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
	at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
	at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
	at javafx.graphics/javafx.stage.Window.hide(Window.java:1199)
	at javafx.graphics/com.sun.javafx.stage.WindowPeerListener.closed(WindowPeerListener.java:105)
	at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:144)
	at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:40)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.lambda$handleWindowEvent$4(GlassWindowEventHandler.java:176)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
	at javafx.graphics/com.sun.javafx.tk.quantum.GlassWindowEventHandler.handleWindowEvent(GlassWindowEventHandler.java:174)
	at javafx.graphics/com.sun.glass.ui.Window.handleWindowEvent(Window.java:1351)
	at javafx.graphics/com.sun.glass.ui.Window.notifyDestroy(Window.java:1260)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkWindow._close(Native Method)
	at javafx.graphics/com.sun.glass.ui.Window.close(Window.java:352)
	at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.lambda$close$4(WindowStage.java:822)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithRenderLock(QuantumToolkit.java:430)
	at javafx.graphics/com.sun.javafx.tk.quantum.WindowStage.close(WindowStage.java:815)
	at javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1141)
	at javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
	at javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
	at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174)
	at javafx.graphics/javafx.stage.Window.hide(Window.java:1199)
	at GlassCrash.lambda$exit$3(GlassCrash.java:101)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
	at java.base/java.lang.Thread.run(Thread.java:830)
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fe41ac60d33, pid=30962, tid=30986
#
# JRE version: OpenJDK Runtime Environment (13.0.1+9) (build 13.0.1+9)
# Java VM: OpenJDK 64-Bit Server VM (13.0.1+9, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  [libglassgtk3.so+0x1fd33]  Java_com_sun_glass_ui_gtk_GtkWindow_setVisibleImpl+0x13
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /localhome/kcr/javafx/tmp/core.30962)
#
# An error report file with more information is saved as:
# /localhome/kcr/javafx/tmp/hs_err_pid30962.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)

------------------------------------

This is not a new issue, since it happens at least as far back as 8u60. It was uncovered while reviewing the unit test for JDK-8232811.
Comments
Sorry, It was not really a conclusion. The only conclusion is that glass native side is receiving calls after it was disposed, so the internal gtk_widget (which is the window) is not available anyome (gtk_widget_destroy gets called), so the crash occurs.
15-02-2020

I don't agree with the conclusion that this is a bug in Dialog. There should never be anything that a Dialog or any other Control can do that will cause a crash. I still think this is a bug in glass -- either in the native code or in the platform-specific Java code.
14-02-2020

This does not seem like a glass issue. I have looked into it: - Java side calls functions after close (that's why there is a null pointer exception). The call occurs after gtk_widget_destroy() so there is no widget when glass functions are called. Checking for is_dead() on every function would look bad. gtk_widget_destroy is on the class finalizer. Commenting this avoids the error: testDialog.getDialogPane().getScene().getWindow().addEventHandler(WindowEvent.WINDOW_HIDDEN, e -> Platform.runLater(dialogHideLatch::countDown)); Probably a bug on the Dialog.
14-02-2020