RFR: 8343531: Improve print_location for invalid heap pointers
Volker Simonis
simonis at openjdk.org
Thu Nov 7 12:13:47 UTC 2024
On Tue, 5 Nov 2024 05:35:57 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
>>> > but I think it is not trivial.
>>>
>>> I was thinking copying the Serial impl into `ParallelScavengeHeap::block_start`; nothing sophisticated.
>>>
>>
>> Unfortunately, the Serial implementation doesn't really work reliably if running with `-XX:+UseTLAB` (which is the default). If called with a pointer which points into unallocated TLAB buffer, `ContiguousSpace::block_start_const()` will just crash with a SIGSEGV (or a secondary crash during error reporting when called from `VMError`):
>>
>> #0 0x00007ffff57d78ce in oopDesc::size_given_klass (this=0x7ffde5616c70, klass=0x7ffda2000000) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/oops/oop.inline.hpp:196
>> #1 0x00007ffff57d7756 in oopDesc::size (this=0x7ffde5616c70) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/oops/oop.inline.hpp:153
>> #2 0x00007ffff689a421 in ContiguousSpace::block_start_const (this=0x7ffff004c880, p=0x7ffde5616ca0) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/gc/shared/space.cpp:565
>> #3 0x00007ffff689b7ba in Space::block_start (this=0x7ffff004c880, p=0x7ffde5616ca0) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/gc/shared/space.inline.hpp:43
>> #4 0x00007ffff60f4144 in GenerationBlockStartClosure::do_space (this=0x7ffff530ef30, s=0x7ffff004c880) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/gc/shared/generation.cpp:191
>> #5 0x00007ffff5e560c5 in DefNewGeneration::space_iterate (this=0x7ffff004b9c0, blk=0x7ffff530ef30, usedOnly=false) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/gc/serial/defNewGeneration.cpp:674
>> #6 0x00007ffff60f3527 in Generation::block_start (this=0x7ffff004b9c0, p=0x7ffde5616ca0) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/gc/shared/generation.cpp:200
>> #7 0x00007ffff60e36e9 in GenCollectedHeap::block_start (this=0x7ffff0038450, addr=0x7ffde5616ca0) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/gc/shared/genCollectedHeap.cpp:884
>> #8 0x00007ffff60e5b97 in BlockLocationPrinter<GenCollectedHeap>::base_oop_or_null (addr=0x7ffde5616ca0) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/gc/shared/locationPrinter.inline.hpp:41
>> #9 0x00007ffff60e592b in BlockLocationPrinter<GenCollectedHeap>::print_location (st=0x7ffff0000b60, addr=0x7ffde5616ca0) at /priv/simonisv/OpenJDK/Git/jdk21u-dev/src/hotspot/share/gc/shared/locationPrinter.inline.hpp:56
>> #10 0x00007ffff60e43bd in GenCollectedHeap::print_location (this=0x7ffff0038450, st=0x7ffff0000b60, a...
>
>> And that's again because the heap is in general not walkable when we call this function.
>
> It depends on exactly when this function can be called, and with what arg. I wonder whether it can be called with a pointer to a obj that has not been properly initialized (with klass); if so, the heap is almost never walkable, since allocation is not atomic.
>
>> the Serial implementation doesn't really work reliably
>
> I am curious if other GCs' impl work (more) reliably, with regarding to the tlab example.
Thanks @albertnetymk, @tschatzl and @shipilev for your reviews.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21870#issuecomment-2462078214
More information about the hotspot-gc-dev
mailing list