JDK-8340849 : [macos] Crash when creating a child window of a JavaFX window after Platform::exit
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: 8u172,10,jfx23
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2024-09-24
  • Updated: 2024-11-16
  • Resolved: 2024-10-30
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
jfx24 b16Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
To reproduce, reenable the skipped SwingNodePlatformExitCrashTest in JavaFX and run it. I'll also try to attach a standalone test program.

This is related to JDK-8190329, which has been fixed in both AWT and (via JDK-8339178) in JavaFX, but has a different root cause.

As noted in test bug JDK-8340442, there were two separate crashes with two separate, but similar, scenarios.

* FX toolkit is started first, and thus JavaFX owns the NSApplication: The crash reported in JDK-8190329 (and later cloned by JDK-8339178 on the FX side) only happens in this mode, where the FX toolkit is started first (e.g., if the main class extends javafx.applicationApplication). The crash was a result of shutting down the FX toolkit, which detached the AppKit thread from the JVM and thus invalidated any cached JNI env pointers, and then creating a Swing Dialog, which used the stale JNI env pointer. As noted, this one is now fixed in both FX and AWT.

* AWT toolkit is started first, and thus AWT owns the NSApplication: This crash is also the result of shutting down the FX toolkit and then creating a Swing Dialog; based on the stack trace, it looks like this crash happens when the AWT dialog tries to create the underlying Window as a child window of the FX window, but the FX parent window pointer is invalid.

This bug tracks the second of these two crashes.

NOTE: It is possible that other platforms (e.g., Windows) could have the same problem, although that will need to be tested.


Steps to reproduce:

1. Comment out the `@Disabled` statement in SwingNodePlatformExitCrashTest
2. Run the following:
gradle sdk shims
gradle --continue --info -PTEST_ONLY=true -PFULL_TEST=true -PUSE_ROBOT=true :systemTests:test --tests SwingNodePlatformExitCrashTest

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000019d821c34, pid=79001, tid=78087
#
# JRE version: Java(TM) SE Runtime Environment (22.0.2+9) (build 22.0.2+9-70)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (22.0.2+9-70, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# C  [libobjc.A.dylib+0x9c34]  objc_msgSend+0x34
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/kcr/dev/javafx/jfx-clean/jfx/rt/tests/system/hs_err_pid79001.log
[3.933s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
#   https://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.
#
Comments
Changeset: 501f761c Branch: master Author: Prasanta Sadhukhan <psadhukhan@openjdk.org> Date: 2024-10-30 13:44:28 +0000 URL: https://git.openjdk.org/jfx/commit/501f761c388642c73ce210fb199806eeeda73e54
30-10-2024

Since the proposed fix is entirely in JavaFX, I've changed the component to javafx/swing.
28-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jfx/pull/1614 Date: 2024-10-28 15:01:20 +0000
28-10-2024