From 5b7c4cec5611652dc744c5b5696cb3c01bc714b8 Mon Sep 17 00:00:00 2001 From: Vladimir Kempik Date: Wed, 19 May 2021 15:48:01 +0300 Subject: [PATCH 1/2] JDK-8267235: [macos_aarch64] InterpreterRuntime::throw_pending_exception messing up LR results in crash --- src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 3790951778b0c..e32da1dbb6168 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -678,6 +678,13 @@ void MacroAssembler::call_VM_base(Register oop_result, // do the call, remove parameters MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments, &l); + // lr could be poisoned with PAC signature during throw_pending_exception + // if it was tail-call optimized by compiler, since lr is not callee-saved + // reload it with proper value + ldr(lr, Address(rthread, + JavaThread::frame_anchor_offset() + + JavaFrameAnchor::last_Java_pc_offset())); + // reset last Java frame // Only interpreter should have to clear fp reset_last_Java_frame(true); From edea0a61ce3a7b2bd6452692204b805373007301 Mon Sep 17 00:00:00 2001 From: Vladimir Kempik Date: Thu, 20 May 2021 18:15:08 +0300 Subject: [PATCH 2/2] Update the fix --- src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index e32da1dbb6168..a0986200c8717 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -681,9 +681,7 @@ void MacroAssembler::call_VM_base(Register oop_result, // lr could be poisoned with PAC signature during throw_pending_exception // if it was tail-call optimized by compiler, since lr is not callee-saved // reload it with proper value - ldr(lr, Address(rthread, - JavaThread::frame_anchor_offset() - + JavaFrameAnchor::last_Java_pc_offset())); + adr(lr, l); // reset last Java frame // Only interpreter should have to clear fp