To reproduce this, run the following on a macOS 14.5 Sonoma system:
1. Run the HelloFullscreen program (in apps/toys/Hello)
2. Press the "Exit" button
BUG: This will print an assertion failure message and then crash:
Java has been detached already, but someone is still trying to use it at -[GlassWindow(Overrides) windowDidResignKey:]:/Users/kcr/dev/javafx/jfx-clean/jfx/rt/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Overrides.m:96
Note that on macOS 13.x these same steps will case get an exception as described in JDK-8299738, but no crash.
Following is the complete stack trace for the assertion failure:
Java has been detached already, but someone is still trying to use it at -[GlassWindow(Overrides) windowDidResignKey:]:/Users/kcr/dev/javafx/jfx-clean/jfx/rt/modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Overrides.m:96
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000128ce8e60, pid=61623, tid=259
#
# JRE version: Java(TM) SE Runtime Environment (21.0.2+13) (build 21.0.2+13-LTS-58)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.2+13-LTS-58, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# C [libglass.dylib+0x28e60] -[GlassWindow(Overrides) windowDidResignKey:]+0xd4
#
# 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/tmp/hs_err_pid61623.log
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
0 libglass.dylib 0x0000000128ce8e20 -[GlassWindow(Overrides) windowDidResignKey:] + 148
1 CoreFoundation 0x000000018b4eb144 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
2 CoreFoundation 0x000000018b57f3d8 ___CFXRegistrationPost_block_invoke + 88
3 CoreFoundation 0x000000018b57f320 _CFXRegistrationPost + 440
4 CoreFoundation 0x000000018b4b9678 _CFXNotificationPost + 768
5 Foundation 0x000000018c5d64e4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
6 AppKit 0x000000018eeaf6fc -[NSWindow resignKeyWindow] + 640
7 AppKit 0x000000018f812e3c -[NSWindow _orderOut:calculatingKeyWithOptions:documentWindow:] + 220
8 AppKit 0x000000018ed968a4 NSPerformVisuallyAtomicChange + 108
9 AppKit 0x000000018f814954 -[NSWindow _reallyDoOrderWindowOutRelativeTo:] + 448
10 AppKit 0x000000018f814d24 -[NSWindow _reallyDoOrderWindow:] + 80
11 AppKit 0x000000018f814f74 -[NSWindow _doOrderWindow:] + 264
12 AppKit 0x000000018f81036c -[NSWindow _finishClosingWindow] + 472
13 AppKit 0x000000018efdd7d0 -[NSWindow _close] + 408
14 libglass.dylib 0x0000000128ce95c8 -[GlassWindow_Normal close] + 76
15 Foundation 0x000000018c6463f4 __NSThreadPerformPerform + 264
16 CoreFoundation 0x000000018b4f64d8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
17 CoreFoundation 0x000000018b4f646c __CFRunLoopDoSource0 + 176
18 CoreFoundation 0x000000018b4f623c __CFRunLoopDoSources0 + 340
19 CoreFoundation 0x000000018b4f4dc8 __CFRunLoopRun + 828
20 CoreFoundation 0x000000018b4f4434 CFRunLoopRunSpecific + 608
21 libjli.dylib 0x00000001027591b0 CreateExecutionEnvironment + 400
22 libjli.dylib 0x00000001027552a0 JLI_Launch + 1128
23 java 0x00000001022cbbb4 main + 396
24 dyld 0x000000018b08e0e0 start + 2360