On Fri, 30 Oct 2026 17:48:34 GMT, Chris Plummer <[email protected]> wrote:
>> Long Yang has updated the pull request with a new target base due to a merge
>> or a rebase. The pull request now contains eight commits:
>>
>> - Enable TestJhsdbJstackMixedWithXComp.java on riscv64 while excluding QEMU
>> environments
>> - Enable -fasynchronous-unwind-tables for linux-riscv64
>> - Add try/catch for memory-read exceptions in getSenderFP
>> - RISC-V: Use compiler-defined macros for DWARF register selection
>> - Recover caller return addresses across save helpers
>> - Use the CIE return-address column instead of the hard-coded RA register
>> - Add comment
>> - 8391637: On the RISC-V platform, TestJhsdbJstackMixed has a certain
>> probability of failure
>
> src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.hpp line 110:
>
>> 108: enum DWARF_Register get_ra_register() { return
>> _state.return_address_reg; }
>> 109: int get_offset_from_cfa(enum DWARF_Register reg) {
>> 110: // Malformed DWARF can supply a register number outside the map
>
> In general are we writing our DWARF parsing code to handle malformed DWARF?
> Was there something that triggered the need for this code?
Thanks for pointing this out. This is defensive code, not prompted by a
real-world issue with compiler-generated DWARF.
The `offset_from_cfa` is fixed size. Hand-written assembly could specify a
return-address column outside the initialized register range without supplying
a recovery rule; operator[] would then insert an offset of zero, causing SA to
read the word at CFA as the return address, potentially producing a bogus PC
and an incorrect or truncated stack trace. Returning INT_MAX instead marks the
offset as unavailable and avoids that read.
https://github.com/openjdk/jdk/blob/592affb46a0734aabbf8f185a33d4d3a7a37a021/src/jdk.hotspot.agent/linux/native/libsaproc/dwarf.cpp#L47-L56
I’m happy to remove this check if you prefer.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/33374#discussion_r4438590745