-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8346952 : GetGraphicsStressTest.java fails: Native resources unavailable #25619
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 abaya! A progress list of the required criteria for merging this PR into |
@anass-baya 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:
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 229 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@mrserb) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@anass-baya The following label will be automatically applied to this pull request:
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. |
Webrevs
|
return 0; | ||
} | ||
// Return the default screen. | ||
JNI_CHECK_PEER_GOTO(self, ret); |
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.
I suggest reordering it slightly - this pattern is commonly used in most cases where JNI_CHECK_PEER_GOTO is used:
result...;
AwtWindow *window = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
window = (AwtWindow *)pData;
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.
I still suggest this order.
Also, please add the new bug ID to the GetGraphicsStressTest.
btw I'm still looking into the new test - it always passes for me. Can we tweak it to reproduce the bug more reliably?
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.
I cant reproduce it locally.
I can see it only on CI 20/20 with the new test and 2/20 with the old one
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.
what is the stack trace when the new test fails?
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.
the same stack as the old test. However let me try to enhance it and come back to you
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.
Hello @mrserb,
I've enhanced the new test. It now reproduces the issue consistently (5/5) locally, but only intermittently (6/20) on CI.
Can we proceed like that ?
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.
Hello @mrserb,
What do you think about the test? Does it look good to you?
KR,
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.
looking into it
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.
It is unclear from the diff, but does the PDATA pData have additional space at the beginning?
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.
Yes. it's handled now
Thread thread1 = new Thread(() -> { | ||
for (int i = 0; i < 10; i++) { | ||
f.removeNotify(); | ||
f.addNotify(); |
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.
Note that we call addNotify last, so the frame will not be disposed at the end of the test.
btw, I cannot reproduce the bug even with the updated test. If you look at the stack trace, it seems the error comes from displayChanged, which is not triggered by the test itself
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.
you can use this test:
/*
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.awt.Window;
/**
* @test
* @bug 8346952
* @key headful
*/
public final class BogusFocusableWindowState {
public static void main(String[] args) {
Window frame = new Window(null) {
@Override
public boolean getFocusableWindowState() {
removeNotify();
return true;
}
};
try {
frame.pack();
frame.setVisible(true);
} finally {
frame.dispose();
}
}
}
* @key headful | ||
*/ | ||
|
||
public final class BogusFocusableWindowState { |
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.
please split the long line to 80 chars, also the empty line above is not really necessary.
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.
hello @mrserb,
Of course, it's done. Thank you.
For my proposed test, it does trigger the same exception call stack.
However, yours is better. The reproduction frequency with it is 20/20.
/integrate |
@anass-baya |
Analysis:
We are encountering a race condition in the native code. While retrieving the screen number by calling _getScreenImOn(), the window is disposed. As a result, the AWT-Windows event loop processes the Dispose() call, which triggers UnlinkObjects().
The race condition between the execution paths of these two native methods sometimes causes an exception
Proposed Fix:
While it's possible to introduce a synchronization mechanism, it would not offer any real benefit. The window will be disposed regardless, and we’ll fall back to the default screen. This behavior is already handled in WWindowPeer.java, where a workaround is in place to use the default device when getScreenImOn() returns a non-existent screen number
Therefore, I propose modifying the native method getScreenImOn to return the default device if the peer is being disposed :
Tests Summary:
GetGraphicsStressTest (existing test):
NotifyStressTest (newly added test):
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25619/head:pull/25619
$ git checkout pull/25619
Update a local copy of the PR:
$ git checkout pull/25619
$ git pull https://git.openjdk.org/jdk.git pull/25619/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25619
View PR using the GUI difftool:
$ git pr show -t 25619
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25619.diff
Using Webrev
Link to Webrev Comment