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
⚠️ AI-generated issue — requires human investigation before acting on it.
Summary
perf_signal_handler in src/profiler.rs calls SystemTime::now() to record the sample timestamp. On Linux, this ultimately calls clock_gettime(CLOCK_REALTIME, ...) which is listed as async-signal-safe by POSIX. However, on other platforms (macOS, FreeBSD) and with some libc configurations, the implementation may use internal synchronisation primitives or VDSO calls that are not formally guaranteed to be async-signal-safe by Rust's spec.
Location
src/profiler.rs, line 386:
let sample_timestamp:SystemTime = SystemTime::now();
This is called inside perf_signal_handler, which is declared as async-signal-safe.
Impact
On Linux with glibc/musl, clock_gettime via VDSO is safe in practice.
On macOS, gettimeofday/clock_gettime implementations may acquire locks in certain edge cases (e.g. timezone changes, NTP updates).
If SystemTime::now() is not async-signal-safe on a given platform, it could cause deadlocks or corrupted state when the signal interrupts a thread that holds an internal libc time lock.
Expected behaviour
Either:
Document the platforms where this is known-safe and add a CI note for others.
Replace with a direct libc::clock_gettime(libc::CLOCK_REALTIME, ...) call which is explicitly AS-safe per POSIX, avoiding Rust's std layer.
Use CLOCK_MONOTONIC instead of real time (also AS-safe, and avoids NTP jump edge cases).
Summary
perf_signal_handlerinsrc/profiler.rscallsSystemTime::now()to record the sample timestamp. On Linux, this ultimately callsclock_gettime(CLOCK_REALTIME, ...)which is listed as async-signal-safe by POSIX. However, on other platforms (macOS, FreeBSD) and with some libc configurations, the implementation may use internal synchronisation primitives or VDSO calls that are not formally guaranteed to be async-signal-safe by Rust's spec.Location
src/profiler.rs, line 386:This is called inside
perf_signal_handler, which is declared as async-signal-safe.Impact
clock_gettimevia VDSO is safe in practice.gettimeofday/clock_gettimeimplementations may acquire locks in certain edge cases (e.g. timezone changes, NTP updates).SystemTime::now()is not async-signal-safe on a given platform, it could cause deadlocks or corrupted state when the signal interrupts a thread that holds an internal libc time lock.Expected behaviour
Either:
libc::clock_gettime(libc::CLOCK_REALTIME, ...)call which is explicitly AS-safe per POSIX, avoiding Rust's std layer.CLOCK_MONOTONICinstead of real time (also AS-safe, and avoids NTP jump edge cases).