RFR: 8367609: serviceability/sa/ClhsdbPmap.java fails when built with Clang [v5]

Kevin Walls kevinw at openjdk.org
Wed Sep 17 11:50:54 UTC 2025


On Tue, 16 Sep 2025 08:22:10 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:

>> The problem seems to be in read_lib_segments (ps_core.c), this check is too harsh:
>> 
>> https://github.com/openjdk/jdk/blob/5271448b3a013b2e3edcd619a4a3b975b292dae1/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c#L423-L425
>> 
>> In my run, `existing_map->memsz = 0xe24000`, while the rhs in L425 is `0xe23000`. According to the NT_FILE entry, this segment of `libjvm.so` has file offset 0x67f000. It seems that the linker aligned it down according to the page size (0x1000). The offset of the same segment according to `readelf -l libjvm.so` is 0x67fc80. This additional offset should be added to `p_memsz` to obtain the 0xe24000, which we see in the core dump.
>> 
>> I added some files to the ticket for context.
>> 
>> Passes `tier1` and `tier2`.
>
> Francesco Andreuzzi has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - nn
>  - comment and rename

Hi - Do you still have the same core?  Can you attach a "readelf -a " output from it in the jbs issue with the other (helpful) files?  Would like to see how things get mapped.

It's interesting to me at the moment that in a random build of mine with gcc, libjvm has e.g. 

```  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
...
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x00000000022a5a50 0x00000000022a5a50  R E    0x1000
```				 
..so loadable text is just part of the mapping at the base address, no offset.

A core of that contains:

  LOAD           0x000000003431b000 0x00007f1305a15000 0x0000000000000000
                 0x00000000022a6000 0x00000000022a6000  R E    0x1000


But your clang build has the text with some offset and vaddr:
https://bugs.openjdk.org/secure/attachment/116147/libjvm_sections.txt


Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
...
  LOAD           0x000000000067fc80 0x0000000000680c80 0x0000000000680c80
                 0x0000000000e225c0 0x0000000000e225c0  R E    0x1000

..so does that appear as a distinct PH in the core?

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

PR Comment: https://git.openjdk.org/jdk/pull/27274#issuecomment-3302619729


More information about the serviceability-dev mailing list