Skip to content

8253033: CheckUnhandledOops check fails in ThreadSnapshot::initialize… #123

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

Closed
wants to merge 2 commits into from

Conversation

lmesnik
Copy link
Member

@lmesnik lmesnik commented Sep 10, 2020

The NULL oops are corrupted by CheckUnhandledOops and should be re-written with NULL to pass testing with -XX:+CheckUnhandledOops.


Progress

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

Issue

  • JDK-8253033: CheckUnhandledOops check fails in ThreadSnapshot::initialize(...) ⚠️ Title mismatch between PR and JBS.

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/123/head:pull/123
$ git checkout pull/123

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 10, 2020

👋 Welcome back lmesnik! 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 Pull request is ready for review label Sep 10, 2020
@openjdk
Copy link

openjdk bot commented Sep 10, 2020

@lmesnik The following label will be automatically applied to this pull request: hotspot-runtime.

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 (add|remove) "label" command.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Sep 10, 2020
@mlbridge
Copy link

mlbridge bot commented Sep 10, 2020

Webrevs

@lmesnik
Copy link
Member Author

lmesnik commented Sep 10, 2020

/label serviceability

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Sep 10, 2020
@openjdk
Copy link

openjdk bot commented Sep 10, 2020

@lmesnik
The serviceability label was successfully added.

@@ -886,6 +886,9 @@ void ThreadSnapshot::initialize(ThreadsList * t_list, JavaThread* thread) {
_thread_status == java_lang_Thread::IN_OBJECT_WAIT_TIMED) {

Handle obj = ThreadService::get_current_contended_monitor(thread);
Copy link
Contributor

Choose a reason for hiding this comment

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

There must be a safepoint here then.
I think this would be better and safer if blocker_object and blocker_object_owner are Handles. Can you change them to Handles?

Copy link
Member

Choose a reason for hiding this comment

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

I can't see anywhere a safepoint check would occur in that code. This issue was flagged as being in Loom so perhaps the loom code is different and is what introduces the safepoint check?
But I agree with Coleen that the best solution is to just use Handles.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not loom-specific and reproduced n jdk/jdk with -XX:+CheckUnhandledOops.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think about moving
Handle obj = ThreadService::get_current_contended_monitor(thread);
out of scope of block_object oop visibility?
It is my second patch.

Copy link
Member

Choose a reason for hiding this comment

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

I'm missing something. How can a NULL oop get corrupted even if there is a GC?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a specific of "CheckUnhandledOops"
I've written in bug comment "Another possible fix would be to disable corruption of NULL unhandled oops. They couldn't be changed really."

We discussed it with Coleen and seems that moving NULL oops out of possible safepoint or handling them seems easier option than changing UnhandledOops.cpp to don't corrupt NULL. It is here:

void UnhandledOops::clear_unhandled_oops() {

Copy link
Contributor

Choose a reason for hiding this comment

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

ThreadService::get_current_contended_monitor calls Thread::check_for_dangling_thread_pointer calls ThreadsSMRSupport::is_a_protected_JavaThread_with_lock((JavaThread *) thread),

The potential safepoint is here, where CheckUnhandledOops puts junk in any oop on the stack.

inline bool ThreadsSMRSupport::is_a_protected_JavaThread_with_lock(JavaThread *thread) {
MutexLocker ml(Threads_lock->owned_by_self() ? NULL : Threads_lock);
return is_a_protected_JavaThread(thread);
}

Copy link
Member

Choose a reason for hiding this comment

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

Thanks Coleen. I'm still not sure that CheckUnhandledOops should be touching NULL oops but ...

Leonid the workaround seems okay.

@@ -886,6 +886,9 @@ void ThreadSnapshot::initialize(ThreadsList * t_list, JavaThread* thread) {
_thread_status == java_lang_Thread::IN_OBJECT_WAIT_TIMED) {

Handle obj = ThreadService::get_current_contended_monitor(thread);
Copy link
Member

Choose a reason for hiding this comment

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

I can't see anywhere a safepoint check would occur in that code. This issue was flagged as being in Loom so perhaps the loom code is different and is what introduces the safepoint check?
But I agree with Coleen that the best solution is to just use Handles.

@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@lmesnik This change now passes all automated pre-integration checks. In addition to the automated checks, the change must also fulfill all project specific requirements

After integration, the commit message will be:

8253033: CheckUnhandledOops check fails in ThreadSnapshot::initialize…

Reviewed-by: coleenp, dholmes
  • If you would like to add a summary, use the /summary command.
  • To credit additional contributors, use the /contributor command.
  • To add additional solved issues, use the /issue command.

Since the source branch of this PR was last updated there have been 59 commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge master into your branch, and then specify the current head hash when integrating, like this: /integrate 5c0d985abf7ef89f9a035692fe9db3ef4001bc2c.

➡️ 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 Pull request is ready to be integrated label Sep 11, 2020
@lmesnik
Copy link
Member Author

lmesnik commented Sep 11, 2020

/integrate

@openjdk openjdk bot closed this Sep 11, 2020
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 11, 2020
@openjdk
Copy link

openjdk bot commented Sep 11, 2020

@lmesnik Since your change was applied there have been 59 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

Pushed as commit 306b166.

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

@lmesnik lmesnik deleted the checkhandle branch September 30, 2020 22:11
pfirmstone pushed a commit to pfirmstone/jdk-with-authorization that referenced this pull request Nov 18, 2024
pfirmstone pushed a commit to pfirmstone/jdk-with-authorization that referenced this pull request Nov 18, 2024
pfirmstone pushed a commit to pfirmstone/jdk-with-authorization that referenced this pull request Nov 18, 2024
pfirmstone pushed a commit to pfirmstone/jdk-with-authorization that referenced this pull request Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants