RFR: JDK-8281023: NMT integration into pp debug command does not work [v2]

Zhengyu Gu zgu at openjdk.java.net
Wed Feb 2 13:34:09 UTC 2022


On Wed, 2 Feb 2022 08:22:39 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> JDK-8280289 enhanced the debug pp() command to use NMT if enabled, and to print NMT related info. That is useful, but there are some issues.
>> 
>> On debug, it just asserts, since the empty reserved region we create to hold the output of the mmap-search is created with address=NULL:
>> 
>> 
>> (gdb) call pp(0x7ffff010b030)
>> 
>> "Executing pp"
>> 
>> Thread 2 "java" received signal SIGSEGV, Segmentation fault.
>> 0x00007ffff6721a71 in VirtualMemoryRegion::VirtualMemoryRegion (this=this at entry=0x7ffff5bb2620, addr=addr at entry=0x0, size=size at entry=0) at /shared/projects/openjdk/jdk-jdk/source/src/hotspot/share/services/virtualMemoryTracker.hpp:180
>> 180 assert(addr != NULL, "Invalid address");
>> 
>> 
>> On release we don't assert and get further, but the use of SafeFetch is slightly wrong. It will deny us any NMT data about p if *p==0:
>> 
>> 
>> if (CanUseSafeFetchN() && SafeFetchN((intptr_t*)p, 0) != 0) {
>> 
>> 
>> This patch:
>> - fixes uses of SafeFetch
>> - changes the mmap-region-search-code to not require an empty ReservedMemoryRegion in order to avoid triggering the assert in virtualMemoryTracker.hpp:180
>> - adds a comment about the safe use of pp() in gdb (one needs to switch off signal handling of SIGSEGV for this to work)
>> 
>> Tests:
>> - I tested manually that pp works with different levels of NMT (Linux x64)
>> - GHAs in process
>
> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Zhengyus remarks

Changes requested by zgu (Reviewer).

src/hotspot/share/services/mallocTracker.cpp line 301:

> 299: bool MallocTracker::print_pointer_information(const void* p, outputStream* st) {
> 300:   assert(MemTracker::enabled(), "NMT must be enabled");
> 301:   if (CanUseSafeFetchN() && os::is_readable_pointer(p)) {

`os::is_readable_pointer()` uses `CanUseSafeFetch32()`, you may want to check `CanUseSafeFetch32()` instead of `CanUseSafeFetchN()`.

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

PR: https://git.openjdk.java.net/jdk/pull/7297


More information about the hotspot-dev mailing list