-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8366149: JNI exception pending in Java_sun_awt_X11GraphicsDevice_pGetBounds of awt_GraphicsEnv.c:1484 #27110
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back dnguyen! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@@ -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)) { |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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).
In the scenario where AWT's UNLOCK API encounters a pendingException, the env pointer throws the pendingException (as seen in
awt.h
). However, inJava_sun_awt_X11GraphicsDevice_pGetBounds
, afterAWT_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 afterAWT_UNLOCK
.Progress
Issue
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