Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8231558: [macos] Platform.exit causes assertion error on macOS 10.15 or later #540

Closed

Conversation

kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Jun 22, 2021

This is a fix for the assertion error message that is printed to the console on macOS 10.15 or later when an application calls Platform.exit while a Stage is showing.

The root cause is a latent bug in the JavaFX glass code that was revealed by an apparent change of behavior in macOS. A few of the object deallocation methods, which are called by the Objective C auto-release mechanism, use the standard GET_MAIN_JENV macro to get the JNI environment. The macro will print an assertion warning if Java has been detached. I instrumented the code and can see that GlassViewDelegate::dealloc is now called after the GlassApplication main loop has detached Java. Since we don't control when the dealloc method is called, it is not correct to do the assertion check in those cases. Some of the dealloc methods already skip this assertion check by grabbing the jEnv pointer directly, so we need to fix the others. I added a new variant of the macro called GET_MAIN_JENV_NOWARN with a comment indicating that is suitable for use by the dealloc methods.

In addition to verifying that the test program attached to JBS now exits cleanly with no assertion failure message, I added an automated system test that fails on macOS before the fix and passes after the fix. On other platforms it passes already.

/reviewers 2


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8231558: [macos] Platform.exit causes assertion error on macOS 10.15 or later

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/540/head:pull/540
$ git checkout pull/540

Update a local copy of the PR:
$ git checkout pull/540
$ git pull https://git.openjdk.java.net/jfx pull/540/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 540

View PR using the GUI difftool:
$ git pr show -t 540

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/540.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 22, 2021

👋 Welcome back kcr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Jun 22, 2021
@openjdk
Copy link

openjdk bot commented Jun 22, 2021

@kevinrushforth
The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

@mlbridge
Copy link

mlbridge bot commented Jun 22, 2021

Webrevs

@@ -66,4 +66,6 @@
static final int ERROR_STARTUP_FAILED = 27;

static final int ERROR_ASSERTION_FAILURE = 28;

static final int ERROR_TIMEOUT = 28;
Copy link
Collaborator

@pankaj-bansal pankaj-bansal Jun 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not this be assigned error code 29 instead of 28?

Copy link
Member Author

@kevinrushforth kevinrushforth Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for catching this. I fixed it.

@pankaj-bansal
Copy link
Collaborator

pankaj-bansal commented Jun 27, 2021

The fix looks fine. The attached test case fails without the fix and passes after the fix. I also ran the full test on Mac 10.15 and I don't see issue.

Copy link
Collaborator

@pankaj-bansal pankaj-bansal left a comment

Looks good

@kevinrushforth kevinrushforth requested a review from aghaisas Jun 28, 2021
@aghaisas
Copy link
Collaborator

aghaisas commented Jul 1, 2021

The fix is fine. I tested on macOS 10.15.7.

@openjdk
Copy link

openjdk bot commented Jul 1, 2021

@kevinrushforth This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8231558: [macos] Platform.exit causes assertion error on macOS 10.15 or later

Reviewed-by: pbansal, aghaisas

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 14 new commits pushed to the master branch:

  • cfa60ff: 8268683: JavaFX MediaPlayer onEndOfMedia behaviour different from Javadoc
  • 098c0f3: 8269147: Update GStreamer to version 1.18.4
  • a1be1d5: 8267418: IntelliJ build and test of JavaFX does not work
  • b0d1586: 8266224: GitHub actions: use gcc 10.3 on Linux
  • 12fb4da: 8269259: Remove obsolete apps, tests, and scripts
  • 50ed890: 8269424: Some SuppressWarnings annotations can be more localized
  • 98e5166: 8269244: [IDE] Dependency verification of *-sources.jar fails when doing gradle sync
  • c4cc998: 8196065: ListChangeListener getRemoved() returns items that were not removed.
  • 78179be: 8267554: Support loading stylesheets from data-URIs
  • 3fd4c97: 8234920: Add SpotLight to the selection of 3D light types
  • ... and 4 more: https://git.openjdk.java.net/jfx/compare/13cffbaad4068177d2d3239fa297302c3f94c217...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Ready to be integrated label Jul 1, 2021
@kevinrushforth
Copy link
Member Author

kevinrushforth commented Jul 1, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Jul 1, 2021

Going to push as commit 6403d67.
Since your change was applied there have been 15 commits pushed to the master branch:

  • 61aff1c: 8258499: JavaFX: Move src.zip out of the lib directory
  • cfa60ff: 8268683: JavaFX MediaPlayer onEndOfMedia behaviour different from Javadoc
  • 098c0f3: 8269147: Update GStreamer to version 1.18.4
  • a1be1d5: 8267418: IntelliJ build and test of JavaFX does not work
  • b0d1586: 8266224: GitHub actions: use gcc 10.3 on Linux
  • 12fb4da: 8269259: Remove obsolete apps, tests, and scripts
  • 50ed890: 8269424: Some SuppressWarnings annotations can be more localized
  • 98e5166: 8269244: [IDE] Dependency verification of *-sources.jar fails when doing gradle sync
  • c4cc998: 8196065: ListChangeListener getRemoved() returns items that were not removed.
  • 78179be: 8267554: Support loading stylesheets from data-URIs
  • ... and 5 more: https://git.openjdk.java.net/jfx/compare/13cffbaad4068177d2d3239fa297302c3f94c217...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 1, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Ready to be integrated rfr Ready for review labels Jul 1, 2021
@openjdk
Copy link

openjdk bot commented Jul 1, 2021

@kevinrushforth Pushed as commit 6403d67.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kevinrushforth kevinrushforth deleted the 8231558-platform-exit-fail branch Jul 1, 2021
@mlbridge
Copy link

mlbridge bot commented Jul 2, 2021

Mailing list message from Ty Young on openjfx-dev:

Does this also fix the free(): invalid pointer issue when closing a
JavaFX application on Linux or is that unrelated?

On 7/1/21 6:17 AM, Kevin Rushforth wrote:

1 similar comment
@mlbridge
Copy link

mlbridge bot commented Jul 2, 2021

Mailing list message from Ty Young on openjfx-dev:

Does this also fix the free(): invalid pointer issue when closing a
JavaFX application on Linux or is that unrelated?

On 7/1/21 6:17 AM, Kevin Rushforth wrote:

@mlbridge
Copy link

mlbridge bot commented Jul 2, 2021

Mailing list message from Kevin Rushforth on openjfx-dev:

Unrelated, since this fix is in macOS-specific platform code.

-- Kevin

On 7/1/2021 4:33 AM, Ty Young wrote:

Does this also fix the free(): invalid pointer issue when closing a
JavaFX application on Linux or is that unrelated?

On 7/1/21 6:17 AM, Kevin Rushforth wrote:

1 similar comment
@mlbridge
Copy link

mlbridge bot commented Jul 2, 2021

Mailing list message from Kevin Rushforth on openjfx-dev:

Unrelated, since this fix is in macOS-specific platform code.

-- Kevin

On 7/1/2021 4:33 AM, Ty Young wrote:

Does this also fix the free(): invalid pointer issue when closing a
JavaFX application on Linux or is that unrelated?

On 7/1/21 6:17 AM, Kevin Rushforth wrote:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
3 participants