diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h --- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h @@ -180,14 +180,12 @@ void StackDepotBase::PrintAll() { for (int i = 0; i < kTabSize; ++i) { atomic_uintptr_t *p = &tab[i]; - lock(p); - uptr v = atomic_load(p, memory_order_relaxed); + uptr v = atomic_load(p, memory_order_consume); Node *s = (Node *)(v & ~1UL); for (; s; s = s->link) { Printf("Stack for id %u:\n", s->id); s->load().Print(); } - unlock(p, s); } } diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp @@ -86,6 +86,21 @@ "Stack for id .*#0 0x1.*#1 0x2.*#2 0x3.*#3 0x4.*#4 0x8.*#5 0x9.*"); } +TEST(SanitizerCommon, StackDepotPrintNoLock) { + u32 n = 2000; + for (u32 i = 1; i < n; ++i) { + uptr array[] = {0x111, 0x222, i, 0x444, 0x777}; + StackTrace s(array, ARRAY_SIZE(array)); + CHECK_EQ(i, StackDepotPut(s)); + } + StackDepotPrintAll(); + for (u32 i = 1; i < n; ++i) { + uptr array[] = {0x111, 0x222, i, 0x444, 0x777}; + StackTrace s(array, ARRAY_SIZE(array)); + CHECK_EQ(i, StackDepotPut(s)); + } +} + TEST(SanitizerCommon, StackDepotReverseMap) { uptr array1[] = {1, 2, 3, 4, 5}; uptr array2[] = {7, 1, 3, 0};