JDK-8297131 : Glass bug causes assertion failure when process targets Ventura SDK
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: openjfx19
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2022-11-15
  • Updated: 2022-11-16
  • Resolved: 2022-11-16
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
GlassViewDelegate.m contains an API usage bug that is detected by the macOS Ventura SDK, causing a fatal crash at startup for all JavaFX apps, but only if the process is targeting SDK 13 or above. This won't normally happen because OpenJDK builds etc are compiled on older versions of macOS but at some point, someone will compile their own JDK on Ventura and be puzzled by this problem.

The bug is that before a tracking rect is established in GlassViewDelegate NSView::removeTrackingRect is always called, even if no tracking rect has previously been created. Therefore an initialized-to-zero tracking handle is passed on, which pre-Ventura was accepted but Ventura detects as an error. The fix is simple enough: don't call removeTrackingRect if the rect handle is zero.

To reproduce this bug there are two approaches:

1. The obvious way: compile an OpenJDK from scratch on macOS Ventura.
2. The smart way: grab an existing JDK and use the 'vtool' command to edit the Mach-O version header that contains what SDK version the binary targets. This header is what controls the extra assertions.

How to do it with vtool:

cd $JAVA_HOME/bin
vtool -set-version-min macos 10.12 13 -output ./java ./java
codesign --remove-signature ./java

Now try running any JavaFX app and you'll get the following crash:

2022-11-15 16:49:22.238 java[49927:2091228] *** Assertion failure in -[_NSTrackingAreaAKViewHelper removeTrackingRect:], _NSTrackingAreaAKManager.m:1585
2022-11-15 16:49:22.241 java[49927:2091228] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '0x0 is an invalid NSTrackingRectTag. Common possible reasons for this are: 1. already removed this trackingRectTag, 2. Truncated the NSTrackingRectTag to 32bit at some point.'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007ff800ac543b __exceptionPreprocess + 242
        1   libobjc.A.dylib                     0x00007ff800614e25 objc_exception_throw + 48
        2   Foundation                          0x00007ff801966fb0 -[NSCalendarDate initWithCoder:] + 0
        3   AppKit                              0x00007ff804222562 -[_NSTrackingAreaAKViewHelper removeTrackingRect:] + 190
        4   libglass.dylib                      0x000000010f1a8449 Java_com_sun_glass_ui_mac_MacApplication__1getMacKey + 3593
        5   libglass.dylib                      0x000000010f1ad038 Java_com_sun_glass_ui_mac_MacApplication__1getMacKey + 23032
        6   AppKit                              0x00007ff803bae3a1 -[NSView setFrame:] + 347
        7   libglass.dylib                      0x000000010f1ad095 Java_com_sun_glass_ui_mac_MacApplication__1getMacKey + 23125
        8   AppKit                              0x00007ff803bbf0f9 -[NSView resizeWithOldSuperviewSize:] + 694
        9   AppKit                              0x00007ff803bbea2a -[NSView resizeSubviewsWithOldSize:] + 488
        10  AppKit                              0x00007ff803b9e206 -[NSView setFrameSize:] + 1446
        11  AppKit                              0x00007ff803bae3a1 -[NSView setFrame:] + 347
        12  AppKit                              0x00007ff803bbf0f9 -[NSView resizeWithOldSuperviewSize:] + 694
        13  AppKit                              0x00007ff803bbea2a -[NSView resizeSubviewsWithOldSize:] + 488
        14  AppKit                              0x00007ff803b9e206 -[NSView setFrameSize:] + 1446
        15  AppKit                              0x00007ff803bbce2d -[NSThemeFrame setFrameSize:] + 482
        16  AppKit                              0x00007ff803bbc4f4 -[NSWindow _oldPlaceWindow:fromServer:] + 813
        17  AppKit                              0x00007ff803bbaae5 -[NSWindow _setFrameCommon:display:fromServer:] + 1656
        18  libglass.dylib                      0x000000010f1a027f getImage + 6799
        19  libglass.dylib                      0x000000010f19fcec getImage + 5372
        20  libglass.dylib                      0x000000010f19ff59 getImage + 5993
        21  libglass.dylib                      0x000000010f1b72ce Java_com_sun_glass_ui_mac_MacWindow__1setBounds2 + 446
        22  ???                                 0x0000000117cd253a 0x0 + 4694287674
        23  ???                                 0x0000000117cce42b 0x0 + 4694271019
        24  ???                                 0x0000000117cce42b 0x0 + 4694271019
        25  ???                                 0x0000000117cce42b 0x0 + 4694271019
        26  ???                                 0x0000000117cce88f 0x0 + 4694272143
)
libc++abi: terminating with uncaught exception of type NSException


FREQUENCY : always



Comments
This looks like a duplicate of JDK-8296654.
15-11-2022