RFR: 8267235: [macos_aarch64] InterpreterRuntime::throw_pending_exception messing up LR results in crash

Anton Kozlov akozlov at openjdk.java.net
Thu May 20 11:51:32 UTC 2021


On Wed, 19 May 2021 12:54:03 GMT, Vladimir Kempik <vkempik at openjdk.org> wrote:

> Please review this patch for call_VM_Base routine.
> it's expected there the LR is callee-saved register, but it's not on aarch64.
> when InterpreterRuntime::throw_pending_exception is tail-call optimized,
> the last subroutine before return is pthread_jit_write_protect_np which pac-sign LR.
> It can only be reproduced in macos 11.4beta (just run J2Ddemo ) but in fact affects every aarch64 build.

The change looks good to me, but I'm not a formal reviewer. 

AArch64's StubRoutines::forward_exception_entry below expects LR to point to after the runtime call. Usually LR is preserved by the runtime callee, but this is not required by the ABI [1]. So we need to restore LR after the call.

[1] https://github.com/ARM-software/abi-aa/blob/2bcab1e3b22d55170c563c3c7940134089176746/aapcs64/aapcs64.rst#general-purpose-registers

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp line 686:

> 684:   ldr(lr, Address(rthread,
> 685:                             JavaThread::frame_anchor_offset()
> 686:                             + JavaFrameAnchor::last_Java_pc_offset()));

`ldr(lr, Address(rthread, JavaThread::last_Java_pc_offset()))`? Same meaning, but shorter.

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

Marked as reviewed by akozlov (Committer).

PR: https://git.openjdk.java.net/jdk/pull/4115


More information about the hotspot-runtime-dev mailing list