RFR: 8343343: Misc crash dump improvements on more platforms after JDK-8294160 [v3]

Boris Ulasevich bulasevich at openjdk.org
Wed Nov 6 08:59:28 UTC 2024


On Tue, 5 Nov 2024 13:45:52 GMT, Martin Doerr <mdoerr at openjdk.org> wrote:

> Maybe we'll get an arm32 part from @bulasevich.

Hi Martin,

I believe this would be the appropriate change for ARM32:


--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
+++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp
@@ -188,9 +188,27 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
   intptr_t* sp;
   intptr_t* fp;
   address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
+  if (!is_readable_pointer(epc)) {
+    // Try to recover from calling into bad memory
+    // Assume new frame has not been set up, the same as
+    // compiled frame stack bang
+    return fetch_compiled_frame_from_context(ucVoid);
+  }
   return frame(sp, fp, epc);
 }

+frame os::fetch_compiled_frame_from_context(const void* ucVoid) {
+  const ucontext_t* uc = (const ucontext_t*)ucVoid;
+  // In compiled code, the stack banging is performed before LR
+  // has been saved in the frame.  LR is live, and SP and FP
+  // belong to the caller.
+  intptr_t* fp = os::Linux::ucontext_get_fp(uc);
+  intptr_t* sp = os::Linux::ucontext_get_sp(uc);
+  address pc = (address)(uc->uc_mcontext.arm_lr
+                         - NativeInstruction::instruction_size);
+  return frame(sp, fp, pc);
+}
+
 frame os::get_sender_for_C_frame(frame* fr) {
 #ifdef __thumb__
   // We can't reliably get anything from a thumb C frame.

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

PR Comment: https://git.openjdk.org/jdk/pull/21809#issuecomment-2459047177


More information about the hotspot-runtime-dev mailing list