On Thu, 15 Oct 2026 04:52:38 GMT, Yasumasa Suenaga <[email protected]> wrote:

>> Alpine Linux would not provide `.eh_frame` enough to unwind in both regular 
>> binary and debuginfo. We need to refer `.debug_frame` in debuginfo for 
>> unwinding.
>> 
>> This ticket also re-enable mixed jstack jtreg tests on Alpine if musl-c 
>> debuginfo is available because `.debug_frame` would be provided by musl-dbg 
>> package.
>> This change passed all of serviceability/sa jtreg tests on following 
>> environment:
>> 
>> - Fedora 44 x86_64
>> - Alpine Linux 3.23 (with musl-dbg) x86_64
>> - Rocky Linux 9.5 aarch64
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Yasumasa Suenaga has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Skip tests on musl c on AArch64

src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp line 81:

> 79:   uint64_t length = *(reinterpret_cast<uint32_t *>(_buf));
> 80:   _buf += 4;
> 81:   if (!_lib->frame.is_debug_frame && length == 0xffffffff) {

I believe this check is incorrect. .debug_frame still uses 0xffffffff to 
indicate that a 64-bit length follows.

src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp line 102:

> 100:   unsigned char *end = _buf + length;
> 101: 
> 102:   _buf += 4; // Skip ID (This value of CIE would be always 0 in 
> .eh_frame / 0xffffffff in .debug_frame)

But his isn't true of DWARF64, which you seem to be partially supporting on 
lines 81-83 above.

src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp line 103:

> 101: 
> 102:   _buf += 4; // Skip ID (This value of CIE would be always 0 in 
> .eh_frame / 0xffffffff in .debug_frame)
> 103:   _buf++;    // Skip version

This will break with version 4 CIE because it adds additional info at the 
start. Will this ever be an issue for us?

src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp line 348:

> 346:   while (_buf <= end) {
> 347:     uint64_t length = get_entry_length();
> 348:     if (length == 0L) {

If this is a .debug_frame, it won't end with a zero-length terminator. You need 
to do bounds checks to make sure you are not reading past the end of the buffer.

src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp line 354:

> 352:     unsigned char *start_of_entry = _buf;
> 353:     uint32_t id = *(reinterpret_cast<uint32_t *>(_buf));
> 354:     _buf += 4;

But his isn't 4 bytes for DWARF64, which you seem to be partially supporting on 
lines 81-83 above.

src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp line 412:

> 410:         free(_lib->frame.data);
> 411:       }
> 412:       memcpy(&_lib->frame, &frame, sizeof(frame_info));

You are freeing and replacing the .eh_frame with the .debug_frame, which means 
a subsequent parse won't have access to the .eh_frame and will always defer to 
the .debug_frame.

src/jdk.hotspot.agent/linux/native/libsaproc/libproc_impl.c line 298:

> 296:    if (fill_addr_info(newlib)) {
> 297:      if (!read_frame(".eh_frame", newlib->fd, &newlib->frame)) {
> 298:        print_debug("Could not find .eh_frame section in %s\n", 
> newlib->name);

Do we want to support the use case where there is no .eh_frame but there is a 
.debug_frame?

src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c line 414:

> 412:        // we don't need to keep the library open, symtab is already
> 413:        // built. Only for core dump we need to keep the fd open.
> 414:        close(lib->fd);

Why is this removed? Isn't it causing fd leaks?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4288933416
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4288940180
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4288861622
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4288719061
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4288947336
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4288778660
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4288788590
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4288958741

Reply via email to