You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[PROF-15201] fix(profiler): close two TOCTOU races between SIGPROF handler and JFR lifecycle (#614)
fix(profiler): drain in-flight signal handlers before JFR teardown
Close two TOCTOU races between profiling signal handlers and the JFR
lifecycle that could cause use-after-free or hangs during recording-cycle
rotation.
- _enabled: unify __ATOMIC_RELEASE/ACQUIRE across CTimer, CTimerJvmti,
ITimer, ITimerJvmti, PerfEvents, WallClockASGCT, WallClockJvmti so
arm64 handlers cannot observe stale _enabled=true after
disableEngines() has returned.
- Ordering: Profiler::stop() now runs disableEngines() → drain →
per-engine stop() → _jfr.stop(); Profiler::start() enables wall
before its pthread starts and CPU only after _jfr.start() completes.
- Drain: new SignalInflight module + InflightGuard RAII counter on a
dedicated cache line; every JFR-writing signal handler participates.
drain() spins to 0 with a 200 ms deadline; on timeout, stop() returns
Error and leaves _state == RUNNING so retry is safe (no non-idempotent
engine teardown has run).
co-authored by claude
Great reviews from both @rkennke, @jbachorik
0 commit comments