[compiler-rt] [TSan] Fix deadlocks during TSan error reporting on Apple platforms (PR #151495)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 09:54:14 PDT 2026
================
@@ -528,53 +543,81 @@ void AfterSleep(ThreadState *thr, uptr pc) {
void ReportDeadlock(ThreadState *thr, uptr pc, DDReport *r) {
if (r == 0 || !ShouldReport(thr, ReportTypeDeadlock))
return;
- ThreadRegistryLock l(&ctx->thread_registry);
- ScopedReport rep(ReportTypeDeadlock);
- for (int i = 0; i < r->n; i++) {
- rep.AddMutex(r->loop[i].mtx_ctx0, r->loop[i].stk[0]);
- rep.AddUniqueTid((int)r->loop[i].thr_ctx);
- rep.AddThread((int)r->loop[i].thr_ctx);
- }
- uptr dummy_pc = 0x42;
- for (int i = 0; i < r->n; i++) {
- for (int j = 0; j < (flags()->second_deadlock_stack ? 2 : 1); j++) {
- u32 stk = r->loop[i].stk[j];
- StackTrace stack;
- if (stk && stk != kInvalidStackID) {
- stack = StackDepotGet(stk);
- } else {
- // Sometimes we fail to extract the stack trace (FIXME: investigate),
- // but we should still produce some stack trace in the report.
- stack = StackTrace(&dummy_pc, 1);
+ // Use alloca, because malloc during signal handling deadlocks
+ ScopedReport *rep = (ScopedReport *)__builtin_alloca(sizeof(ScopedReport));
----------------
vitalybuka wrote:
> // Use alloca, because malloc during signal
but it was using stack?
https://github.com/llvm/llvm-project/pull/151495
More information about the llvm-commits
mailing list