Skip to content

Conversation

DamonGuy
Copy link
Contributor

@DamonGuy DamonGuy commented Sep 5, 2025

In the scenario where AWT's UNLOCK API encounters a pendingException, the env pointer throws the pendingException (as seen in awt.h). However, in Java_sun_awt_X11GraphicsDevice_pGetBounds, after AWT_UNLOCK, the bounds var is set. The exception check does not occur until after the bounds is set, so the bounds may be set to an undesired value. This fix adds another exception check to look for this pendingException after AWT_UNLOCK.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8366149: JNI exception pending in Java_sun_awt_X11GraphicsDevice_pGetBounds of awt_GraphicsEnv.c:1484 (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27110/head:pull/27110
$ git checkout pull/27110

Update a local copy of the PR:
$ git checkout pull/27110
$ git pull https://git.openjdk.org/jdk.git pull/27110/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27110

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27110.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 5, 2025

👋 Welcome back dnguyen! 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
Copy link

openjdk bot commented Sep 5, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Sep 5, 2025

@DamonGuy The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added client [email protected] rfr Pull request is ready for review labels Sep 5, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 5, 2025

Webrevs

@@ -1286,8 +1286,12 @@ Java_sun_awt_X11GraphicsDevice_pGetBounds(JNIEnv *env, jobject this, jint screen
&xwa);
AWT_UNLOCK ();

bounds = (*env)->NewObject(env, clazz, mid, 0, 0,
xwa.width, xwa.height);
if ((*env)->ExceptionCheck(env)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the problem that we are here because bounds == null and one way this is possible is that the call at line 1265 failed? Meaning threw an unlikely exception.
If so, maybe that is where we should just "return NULL".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding of the issue is that there is a possible pendingException on line 1287. This is possible by AWT_NOFLUSH_UNLOCK_IMPL() in awt.h as you previously pointed me to. Seems like setting bounds by the code that was previously on lines 1289-1290 was unsafe due to the AWT_UNLOCK possibly throwing an exception right before it.

I don't think bounds can be null in this area because line 1279 checks for this. But if the AWT_UNLOCK here is throwing a pendingException, I think returning null is what should be done here since the same is done on line 1297, except this won't be reached in this case until after bounds is unsafely set.

I can just return NULL instead near line 1265 as you suggested, but from what I read, the exception would be at line 1287 (which is after).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants