On Wed, 14 Oct 2026 09:14:01 GMT, Long Yang <[email protected]> wrote:

> Hi, could I have a review of this patch.
> 
> This patch fixes [JDK-8391637](https://bugs.openjdk.org/browse/JDK-8391637).
> 
> On `risc-v`, 
> [LinuxRISCV64CFrame.sender()](https://github.com/openjdk/jdk/blob/c368bac40e185398fbc40dc4d75a457f7a36f954/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/riscv64/LinuxRISCV64CFrame.java#L70)
>  validates only FP alignment, then dereferences FP for SP, link, and return 
> address. An aligned arbitrary FP (such as 0x90) can therefore cause 
> UnmappedAddressException, and lead to incomplete stack for the target thread.
> 
> `aarch64` and `amdf64`already use `dwarf` to unwind native frames, see 
> https://github.com/openjdk/jdk/blob/c368bac40e185398fbc40dc4d75a457f7a36f954/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java#L36
> https://github.com/openjdk/jdk/blob/c368bac40e185398fbc40dc4d75a457f7a36f954/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/linux/aarch64/LinuxAARCH64CFrame.java#L38
> 
> This patch makes `risc-v` to unwind with `dwarf` too. 
> 
> The `risc-v` version basically has the same design as the `aarch64` version. 
> There are also several differences , primarily due to differences in calling 
> conventions.  Almost every difference is accompanied by an explanatory 
> comment.
> 
> I have ran tests in `test/hotspot/jtreg/serviceability/sa` on `risc-v` and 
> `amd64`, all passed.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

### 🔵 Needs a closer look

Architecture-specific unwinding, signal-frame offsets, and shared DWARF parser 
changes require final validation on RISC-V hardware.

**0 open findings**

<details>
<summary><strong>What changed in this PR</strong></summary>

Adds DWARF-based native stack unwinding for Linux RISC-V to prevent incomplete 
SA stack traces caused by invalid frame pointers.

**Changes:**
- Implements RISC-V DWARF register and frame unwinding support.
- Handles RISC-V signal trampolines and continuation frames.
- Extends mixed-stack tests to RISC-V and strengthens failure detection.

| File | Description |
| ---- | ----------- |
| `make/​modules/​jdk.hotspot.agent/​Lib.gmk` | Enables DWARF sources on 
RISC-V. |
| `src/​jdk.hotspot.agent/​linux/​native/​libsaproc/​dwarf.cpp` | Corrects CFI 
processing at PC boundaries. |
| `src/​jdk.hotspot.agent/​linux/​native/​libsaproc/​dwarf.hpp` | Selects 
RISC-V register definitions. |
| `src/​jdk.hotspot.agent/​linux/​native/​libsaproc/​dwarf_regs_riscv64.h` | 
Defines RISC-V DWARF register mappings. |
| 
`src/​jdk.hotspot.agent/​share/​classes/​sun/​jvm/​hotspot/​debugger/​linux/​LinuxCDebugger.java`
 | Uses the new RISC-V top-frame builder. |
| 
`src/​jdk.hotspot.agent/​share/​classes/​sun/​jvm/​hotspot/​debugger/​linux/​LinuxDebugger.java`
 | Recognizes the RISC-V signal trampoline. |
| 
`src/​jdk.hotspot.agent/​share/​classes/​sun/​jvm/​hotspot/​debugger/​linux/​riscv64/​LinuxRISCV64CFrame.java`
 | Implements DWARF-based RISC-V unwinding. |
| 
`src/​jdk.hotspot.agent/​share/​classes/​sun/​jvm/​hotspot/​debugger/​linux/​riscv64/​LinuxRISCV64ThreadContext.java`
 | Restores registers from signal contexts. |
| 
`src/​jdk.hotspot.agent/​share/​classes/​sun/​jvm/​hotspot/​runtime/​riscv64/​RISCV64ContinuationEntry.java`
 | Corrects continuation entry FP calculation. |
| `test/​hotspot/​jtreg/​serviceability/​sa/​TestJhsdbJstackMixed.java` | 
Associates the test with the fixed issue. |
| `test/​hotspot/​jtreg/​serviceability/​sa/​TestJhsdbJstackMixedCore.java` | 
Adds RISC-V coverage and stronger assertions. |
</details>

đź§  **Review effort:** Balanced

---

đź’ˇ <a 
href="/openjdk/jdk/new/master?filename=.github/skills/code-review/SKILL.md" 
class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a 
`code-review` agent skill</a> or configure MCP servers for context-aware, 
tailored reviews. <a 
href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills";
 class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more 
in the docs.</a>

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

PR Review: https://git.openjdk.org/jdk/pull/33358#pullrequestreview-5515719021

Reply via email to