On Fri, 16 Oct 2026 07:23:17 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 two 
> additional commits since the last revision:
> 
>  - Close library FD when lib_info is destroyed
>  - Consider 64bit DWARF

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

> 121:   // address_size and segment_size are located in DWARF 4 or later,
> 122:   // but they are not available in .eh_frame defined by Linux LSB Core 
> Generic 5.0.
> 123:   if (!_lib->frame.is_debug_frame && _dwarf_version >= 4) {

This is suppose to check for extra fields in DWARF 4 or later, but your 
!_lib->frame.is_debug_frame check is backwards. The "!" should be removed.

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

> 372:     if (length == 0L) {
> 373:       break; // it means "terminator" in .eh_frame, so go through to 
> .debug_frame
> 374:     } else if (_buf + length > end) {

You need a check before calling get_entry_length(). Otherwise if _buf == end,  
get_entry_length will read beyond the end of the buffer. I think changing the 
loop to check for "buf < end" is the proper fix.

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

> 373:       break; // it means "terminator" in .eh_frame, so go through to 
> .debug_frame
> 374:     } else if (_buf + length > end) {
> 375:       // unexpected: DWARF is broken?

Should this print a warning?

Is this unexpected because you expect to find the PC in the frame record before 
reaching the end?

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

> 437:       int debug_fd = open_debuginfo(_lib->name, _lib->fd);
> 438:       if (debug_fd != -1 && read_frame(".debug_frame", debug_fd, 
> &frame)) {
> 439:         close(debug_fd);

The close() should be done even if read_frame() fails to find the .debug_frame. 
If the open succeeded, then you need to do the close.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4299838483
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4299824486
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4299716504
PR Review Comment: https://git.openjdk.org/jdk/pull/33375#discussion_r4299861193

Reply via email to