Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix stack-guard corruption on musl/aarch64/jdk11 (PROF-13072)
Introduce start_window_and_register() noinline helper so that
start_routine_wrapper_spec() never has sigset_t (SignalBlocker)
on its own stack frame, preserving the original design that
prevents musl's stack-protector canary corruption on aarch64.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
  • Loading branch information
jbachorik and claude committed Apr 10, 2026
commit 369c788e0071df53113471941fae0f3fbea68195
33 changes: 17 additions & 16 deletions ddprof-lib/src/main/cpp/libraryPatcher_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ static void init_thread_tls() {
ProfiledThread::initCurrentThread();
}

// Arm the CPU timer with profiling signals blocked and open the init window
// (PROF-13072). Kept noinline for the same stack-protector reason as
// delete_routine_info: SignalBlocker's sigset_t must not appear in
// start_routine_wrapper_spec's own stack frame on musl/aarch64.
__attribute__((noinline))
static void start_window_and_register(int tid) {
SignalBlocker blocker;
ProfiledThread::currentSignalSafe()->startInitWindow();
Profiler::registerThread(tid);
}

// Wrapper around the real start routine.
// The wrapper:
// 1. Register the newly created thread to profiler
Expand All @@ -82,22 +93,12 @@ static void init_thread_tls() {
__attribute__((visibility("hidden")))
static void* start_routine_wrapper_spec(void* args) {
RoutineInfo* thr = (RoutineInfo*)args;
func_start_routine routine;
void* params;
int tid;
{
// Keep signals blocked across delete_routine_info, init_thread_tls, and
// registerThread for the same reasons as start_routine_wrapper: ASAN
// lock-ordering and the JVM TLS race window (PROF-13072).
SignalBlocker blocker;
routine = thr->routine();
params = thr->args();
delete_routine_info(thr);
init_thread_tls();
tid = ProfiledThread::currentTid();
ProfiledThread::currentSignalSafe()->startInitWindow();
Profiler::registerThread(tid);
}
func_start_routine routine = thr->routine();
void* params = thr->args();
delete_routine_info(thr);
init_thread_tls();
int tid = ProfiledThread::currentTid();
start_window_and_register(tid);
void* result = routine(params);
Profiler::unregisterThread(tid);
ProfiledThread::release();
Expand Down
Loading