RFR: 8340849: [macos] Crash when creating a child window of a JavaFX window after Platform::exit

Kevin Rushforth kcr at openjdk.org
Tue Oct 29 16:23:18 UTC 2024


On Mon, 28 Oct 2024 15:01:20 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> When AWT toolkit is started first for it to own the "NSApplication" and then FX toolkit is started and shutdown by calling `Platform.exit` and then Swing Dialog is tried to be created, then it is seen that the application crashes as the AWT dialog tries to create the underlying Window as a child window of the FX window (as can be seen [here](https://github.com/openjdk/jdk/blob/9f6211bcf1b46e4bfba2d128d9eb8457bc0cde51/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java#L738-L743) )
> Since the underlying window handle is already invalid, it crashes.
> 
> The fix is made to register shutdown hook when FX toolkit is shutting down so as to notify JLightweightFrame about the invalid window handle when FX toolkit is shutdown and SwingNode disposer is called.
> 
> The regression test is modified to override tearDownOnce as the test method shuts down the JavaFX runtime using `Platform.exit`, then the `teardownOnce `method in the superclass  calls `Util.shutdown`, which times out waiting for a runnable to run, which it never will since the toolkit is already shutdown

I finished my testing, and everything looks good. With the fix, the test passes cleanly on all platforms

Without the fix, the test crashes on macOS (as indicated in the bug report), and gets the following exception on Windows (which doesn't cause the test to fail, but does result in a message to stderr).


SwingNodePlatformExitCrashTest > testPlatformExitBeforeShowHoldEDT() STANDARD_ERROR
    Exception in thread "AWT-EventQueue-0" java.lang.InternalError: Invalid window handle.

        at java.desktop/sun.awt.windows.WToolkit.eventLoop(Native Method)
        at java.desktop/sun.awt.windows.WToolkit.run(WToolkit.java:297)
        at java.base/java.lang.Thread.run(Thread.java:1575)

@lukostyra Can you be the second reviewer?

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

Marked as reviewed by kcr (Lead).

PR Review: https://git.openjdk.org/jfx/pull/1614#pullrequestreview-2402470264
PR Comment: https://git.openjdk.org/jfx/pull/1614#issuecomment-2444759248


More information about the openjfx-dev mailing list