Commit f80a97c
committed
fix: prevent deadlocks when instrumenting with clippy-tracing
Two deadlock sources exist when clippy-tracing instruments the codebase:
1. Logger::update() called open_file_nonblock() while holding the LOGGER
mutex. When instrumented, that function calls log::trace!() which
re-enters Logger::log() and attempts to acquire the same non-reentrant
mutex, causing a deadlock on startup.
2. Signal handlers (extern C fns) were instrumented by clippy-tracing,
adding mutex acquisitions in async-signal-unsafe contexts. When a
signal interrupted a thread already holding the LOGGER mutex, the
handler would deadlock trying to acquire it again.
Fix (1) by moving the open_file_nonblock() call before the mutex is
acquired in Logger::update(). Fix (2) by teaching clippy-tracing to
skip functions with an explicit ABI (e.g. extern C), since these are
typically signal handlers or FFI callbacks that must not acquire locks.
Closes #58071 parent ccb096d commit f80a97c
2 files changed
Lines changed: 4 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 131 | + | |
135 | 132 | | |
136 | 133 | | |
137 | 134 | | |
| |||
166 | 163 | | |
167 | 164 | | |
168 | 165 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 166 | + | |
173 | 167 | | |
174 | 168 | | |
175 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
| 435 | + | |
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
| |||
0 commit comments