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

8316746: Top of lock-stack does not match the unlocked object #16345

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/hotspot/share/opto/locknode.cpp
Original file line number Diff line number Diff line change
@@ -202,9 +202,17 @@ void Parse::do_monitor_exit() {
// OSR compiled methods can start with lock taken
C->set_has_monitors(true);

pop(); // Pop oop to unlock
Node* obj = pop(); // Pop oop to unlock
// Because monitors are guaranteed paired (else we bail out), we know
// the matching Lock for this Unlock. Hence we know there is no need
// for a null check on Unlock.
shared_unlock(map()->peek_monitor_box(), map()->peek_monitor_obj());
// In case of OSR compilation, the monitor may have been transferred
// from the interpreter frame. Using map()->peek... may return them
// in wrong order. We should use the popped obj.
if (LockingMode == LM_LEGACY) {
// May potentially be the wrong one in case of OSR, but we need both, box and obj.
Copy link
Member

Choose a reason for hiding this comment

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

This appears to mask the real problem, which, unless I missed it, has not been explained yet.

shared_unlock(map()->peek_monitor_box(), map()->peek_monitor_obj());
} else {
shared_unlock(/* unused */ zerocon(T_ADDRESS), obj);
}
}
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/macro.cpp
Original file line number Diff line number Diff line change
@@ -2241,7 +2241,7 @@ void PhaseMacroExpand::expand_unlock_node(UnlockNode *unlock) {
Node* obj = unlock->obj_node();
Node* box = unlock->box_node();

assert(!box->as_BoxLock()->is_eliminated(), "sanity");
assert(box->is_Con() || !box->as_BoxLock()->is_eliminated(), "sanity");

// No need for a null check on unlock