RFR: 8247972: incorrect implementation of JVM TI GetObjectMonitorUsage [v22]
David Holmes
dholmes at openjdk.org
Mon Mar 11 02:24:58 UTC 2024
On Tue, 5 Mar 2024 09:04:08 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:
>> The loop is endless without this extra condition, so we are getting a test execution timeout.
>> The `waiters` seems to be `circular doubly linked list` as we can see below:
>>
>> inline void ObjectMonitor::AddWaiter(ObjectWaiter* node) {
>> assert(node != nullptr, "should not add null node");
>> assert(node->_prev == nullptr, "node already in list");
>> assert(node->_next == nullptr, "node already in list");
>> // put node at end of queue (circular doubly linked list)
>> if (_WaitSet == nullptr) {
>> _WaitSet = node;
>> node->_prev = node;
>> node->_next = node;
>> } else {
>> ObjectWaiter* head = _WaitSet;
>> ObjectWaiter* tail = head->_prev;
>> assert(tail->_next == head, "invariant check");
>> tail->_next = node;
>> head->_prev = node;
>> node->_next = head;
>> node->_prev = tail;
>> }
>> }
>>
>> I'll make sure nothing is missed and check the old code again.
>
> Okay. Now I see why the old code did not have endless loops.
Apologies I should have checked the code - I'd forgotten the list is circular to avoid needing an explicit tail pointer.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17680#discussion_r1519058800
More information about the hotspot-dev
mailing list