RFR: 8340392: Handle OopStorage in location decoder [v3]

Kim Barrett kbarrett at openjdk.org
Wed Sep 18 22:11:36 UTC 2024


On Wed, 18 Sep 2024 19:31:39 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Another debugging QoL improvement.  Currently, when there is a pointer into `OopStorage` that we need to decode for the error log, we just print:
>> 
>>   0x00007ad45c169e10 into live malloced block starting at 0x00007ad45c169dd0, size 632, tag mtInternal
>> 
>> 
>> This is reported by NMT after [JDK-8304815](https://bugs.openjdk.org/browse/JDK-8304815). It is likely worse without NMT. We can actually decode which block in which `OopStorage` the address likely belongs to. This becomes handy when debugging GC crashes that involve `OopStorage`-handled roots.
>> 
>> This patch is able to print the following instead:
>> 
>> 
>>   0x0000000102c05bd0 is a pointer 2/64 into block 0 in oop storage "VM Global"
>
> Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix 32-bit builds

Changes requested by kbarrett (Reviewer).

src/hotspot/share/gc/shared/oopStorage.cpp line 1151:

> 1149: bool OopStorage::Block::print_containing(oop* addr, outputStream* st) {
> 1150:   if (contains(addr)) {
> 1151:     st->print(INTPTR_FORMAT " is a pointer %u/" SIZE_FORMAT " into block %zu",

s/SIZE_FORMAT/%zu/
s/INTPTR_FORMAT/PTR_FORMAT/ - because it's semantically a pointer.

src/hotspot/share/runtime/os.cpp line 1322:

> 1320: 
> 1321:   // Ask if any OopStorage knows about this address.
> 1322:   if (OopStorageSet::print_containing((oop*)addr, st)) {

`addr` might not be oop-aligned, in which case this cast and use might lead to UB.  I think this should
be gated on `is_aligned(addr, alignof(oop))`.

test/hotspot/gtest/gc/shared/test_oopStorageSet.cpp line 109:

> 107: class OopStorageSetTest::VM_PrintAtSafepoint : public VM_GTestExecuteAtSafepoint {
> 108: private:
> 109:  class PrintContainingClosure : public Closure {

Need another leading space here for proper indentation.

-------------

PR Review: https://git.openjdk.org/jdk/pull/21072#pullrequestreview-2313718283
PR Review Comment: https://git.openjdk.org/jdk/pull/21072#discussion_r1765673490
PR Review Comment: https://git.openjdk.org/jdk/pull/21072#discussion_r1765789363
PR Review Comment: https://git.openjdk.org/jdk/pull/21072#discussion_r1765756516


More information about the hotspot-dev mailing list