llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) <details> <summary>Changes</summary> PR #<!-- -->151495 delayed symbolization for memory accesses, locations, threads, and mutexes until OutputReport (after ThreadRegistryLock is released), but missed ScopedReport::AddStack and ScopedReport::AddSleep. As a result, ReportRace (via AddSleep) and ReportMutexMisuse, ReportDeadlock, and ReportDestroyLocked (via AddStack) still invoked the symbolizer while holding ThreadRegistryLock. Store the unsymbolized stack traces and sleep stack ID in ReportDesc and symbolize them in ScopedReport::SymbolizeStackElems(). Assisted-by: Gemini --- Full diff: https://github.com/llvm/llvm-project/pull/228795.diff 2 Files Affected: - (modified) compiler-rt/lib/tsan/rtl/tsan_report.h (+7) - (modified) compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp (+15-4) ``````````diff diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.h b/compiler-rt/lib/tsan/rtl/tsan_report.h index 53bb21964dbba..39e93570469c0 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_report.h +++ b/compiler-rt/lib/tsan/rtl/tsan_report.h @@ -110,11 +110,17 @@ struct AddedLocationAddr { usize locs_idx; }; +struct AddedStack { + StackTrace stack_trace; + bool suppressable = false; +}; + class ReportDesc { public: ReportType typ; uptr tag; Vector<ReportStack*> stacks; + Vector<AddedStack> added_stacks; Vector<ReportMop*> mops; Vector<ReportLocation*> locs; Vector<AddedLocationAddr> added_location_addrs; @@ -122,6 +128,7 @@ class ReportDesc { Vector<ReportThread*> threads; Vector<Tid> unique_tids; ReportStack *sleep; + StackID sleep_stack_id = 0; int count; int signum = 0; diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp index 52a462617ecb4..5644456bb2864 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp @@ -173,9 +173,7 @@ ScopedReport::ScopedReport(ReportType typ, uptr tag) { ScopedReport::~ScopedReport() { DestroyAndFree(rep_); } void ScopedReport::AddStack(StackTrace stack, bool suppressable) { - ReportStack **rs = rep_->stacks.PushBack(); - *rs = SymbolizeStack(stack); - (*rs)->suppressable = suppressable; + rep_->added_stacks.PushBack({stack, suppressable}); } void ScopedReport::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, @@ -202,6 +200,15 @@ void ScopedReport::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, } void ScopedReport::SymbolizeStackElems() { + // symbolize stacks + for (usize i = 0, size = rep_->added_stacks.Size(); i < size; i++) { + AddedStack& as = rep_->added_stacks[i]; + ReportStack* rs = SymbolizeStack(as.stack_trace); + if (rs) + rs->suppressable = as.suppressable; + rep_->stacks.PushBack(rs); + } + // symbolize memory ops for (usize i = 0, size = rep_->mops.Size(); i < size; i++) { ReportMop *mop = rep_->mops[i]; @@ -249,6 +256,10 @@ void ScopedReport::SymbolizeStackElems() { ReportMutex *rm = rep_->mutexes[i]; rm->stack = SymbolizeStackId(rm->stack_id); } + +#if !SANITIZER_GO + rep_->sleep = SymbolizeStackId(rep_->sleep_stack_id); +#endif } void ScopedReport::AddUniqueTid(Tid unique_tid) { @@ -381,7 +392,7 @@ void ScopedReport::AddLocation(uptr addr, uptr size) { #if !SANITIZER_GO void ScopedReport::AddSleep(StackID stack_id) { - rep_->sleep = SymbolizeStackId(stack_id); + rep_->sleep_stack_id = stack_id; } #endif `````````` </details> https://github.com/llvm/llvm-project/pull/228795 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
