From 87c03cb0296811f27a6e35dc298a8dd5a0544317 Mon Sep 17 00:00:00 2001 From: Andrei Pangin Date: Tue, 16 Jul 2024 21:59:18 +0100 Subject: [PATCH] Fix unsafe access to CodeCache --- ddprof-lib/src/main/cpp/stackWalker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ddprof-lib/src/main/cpp/stackWalker.cpp b/ddprof-lib/src/main/cpp/stackWalker.cpp index 24b56f79d..7e19ed693 100644 --- a/ddprof-lib/src/main/cpp/stackWalker.cpp +++ b/ddprof-lib/src/main/cpp/stackWalker.cpp @@ -158,7 +158,8 @@ int StackWalker::walkDwarf(void *ucontext, const void **callchain, } if (CodeHeap::contains(pc) && !(depth == 0 && frame.unwindAtomicStub(pc))) { const void* page_start = (const void*)((uintptr_t)pc & ~0xfffUL); - frame.adjustSP(page_start, pc, sp); + // Don't dereference pc as it may point to unreadable memory + // frame.adjustSP(page_start, pc, sp); java_ctx->set(pc, sp, fp); break; }