[compiler-rt] 36bd9ae - [sanitizer] VReport BeforeFork/AfterFork (#111900)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 13:12:39 PDT 2024
Author: Vitaly Buka
Date: 2024-10-10T13:12:36-07:00
New Revision: 36bd9aebc428413a94f77e8daa679d1937dc2b63
URL: https://github.com/llvm/llvm-project/commit/36bd9aebc428413a94f77e8daa679d1937dc2b63
DIFF: https://github.com/llvm/llvm-project/commit/36bd9aebc428413a94f77e8daa679d1937dc2b63.diff
LOG: [sanitizer] VReport BeforeFork/AfterFork (#111900)
Forks are common suspects for unusual sanitizer behavior.
It can be handy to see them without rebuild.
Added:
Modified:
compiler-rt/lib/asan/asan_posix.cpp
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/hwasan/hwasan_linux.cpp
compiler-rt/lib/lsan/lsan_posix.cpp
compiler-rt/lib/msan/msan_linux.cpp
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_posix.cpp b/compiler-rt/lib/asan/asan_posix.cpp
index 4ee8d7d399e95c..39685696a0d0dd 100644
--- a/compiler-rt/lib/asan/asan_posix.cpp
+++ b/compiler-rt/lib/asan/asan_posix.cpp
@@ -149,6 +149,7 @@ void PlatformTSDDtor(void *tsd) {
# endif
static void BeforeFork() {
+ VReport(2, "BeforeFork tid: %llu\n", GetTid());
if (CAN_SANITIZE_LEAKS) {
__lsan::LockGlobal();
}
@@ -168,6 +169,7 @@ static void AfterFork(bool fork_child) {
if (CAN_SANITIZE_LEAKS) {
__lsan::UnlockGlobal();
}
+ VReport(2, "AfterFork tid: %llu\n", GetTid());
}
void InstallAtForkHandler() {
diff --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 03147a79ed6543..dbc00d7ac3ea39 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -2859,6 +2859,7 @@ WRAPPER_ALIAS(__isoc99_sscanf, sscanf)
WRAPPER_ALIAS(__isoc23_sscanf, sscanf)
static void BeforeFork() {
+ VReport(2, "BeforeFork tid: %llu\n", GetTid());
StackDepotLockBeforeFork();
ChainedOriginDepotLockBeforeFork();
}
@@ -2866,6 +2867,7 @@ static void BeforeFork() {
static void AfterFork(bool fork_child) {
ChainedOriginDepotUnlockAfterFork(fork_child);
StackDepotUnlockAfterFork(fork_child);
+ VReport(2, "AfterFork tid: %llu\n", GetTid());
}
SANITIZER_INTERFACE_ATTRIBUTE
diff --git a/compiler-rt/lib/hwasan/hwasan_linux.cpp b/compiler-rt/lib/hwasan/hwasan_linux.cpp
index d174fb882ca483..68651d3d39d03e 100644
--- a/compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_linux.cpp
@@ -528,6 +528,7 @@ uptr TagMemoryAligned(uptr p, uptr size, tag_t tag) {
}
static void BeforeFork() {
+ VReport(2, "BeforeFork tid: %llu\n", GetTid());
if (CAN_SANITIZE_LEAKS) {
__lsan::LockGlobal();
}
@@ -547,6 +548,7 @@ static void AfterFork(bool fork_child) {
if (CAN_SANITIZE_LEAKS) {
__lsan::UnlockGlobal();
}
+ VReport(2, "AfterFork tid: %llu\n", GetTid());
}
void HwasanInstallAtForkHandler() {
diff --git a/compiler-rt/lib/lsan/lsan_posix.cpp b/compiler-rt/lib/lsan/lsan_posix.cpp
index ddd9fee07e89d2..593000b9eef991 100644
--- a/compiler-rt/lib/lsan/lsan_posix.cpp
+++ b/compiler-rt/lib/lsan/lsan_posix.cpp
@@ -97,6 +97,7 @@ void InstallAtExitCheckLeaks() {
}
static void BeforeFork() {
+ VReport(2, "BeforeFork tid: %llu\n", GetTid());
LockGlobal();
LockThreads();
LockAllocator();
@@ -108,6 +109,7 @@ static void AfterFork(bool fork_child) {
UnlockAllocator();
UnlockThreads();
UnlockGlobal();
+ VReport(2, "AfterFork tid: %llu\n", GetTid());
}
void InstallAtForkHandler() {
diff --git a/compiler-rt/lib/msan/msan_linux.cpp b/compiler-rt/lib/msan/msan_linux.cpp
index 894cf17002bbc0..7140de7e9c5432 100644
--- a/compiler-rt/lib/msan/msan_linux.cpp
+++ b/compiler-rt/lib/msan/msan_linux.cpp
@@ -302,6 +302,7 @@ void MsanTSDDtor(void *tsd) {
# endif
static void BeforeFork() {
+ VReport(2, "BeforeFork tid: %llu\n", GetTid());
// Usually we lock ThreadRegistry, but msan does not have one.
LockAllocator();
StackDepotLockBeforeFork();
@@ -313,6 +314,7 @@ static void AfterFork(bool fork_child) {
StackDepotUnlockAfterFork(fork_child);
UnlockAllocator();
// Usually we unlock ThreadRegistry, but msan does not have one.
+ VReport(2, "AfterFork tid: %llu\n", GetTid());
}
void InstallAtForkHandler() {
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index bf29aa316f6809..5a2d39cd30607f 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -806,6 +806,7 @@ int Finalize(ThreadState *thr) {
#if !SANITIZER_GO
void ForkBefore(ThreadState* thr, uptr pc) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
+ VReport(2, "BeforeFork tid: %llu\n", GetTid());
GlobalProcessorLock();
// Detaching from the slot makes OnUserFree skip writing to the shadow.
// The slot will be locked so any attempts to use it will deadlock anyway.
@@ -847,6 +848,7 @@ static void ForkAfter(ThreadState* thr,
SlotAttachAndLock(thr);
SlotUnlock(thr);
GlobalProcessorUnlock();
+ VReport(2, "AfterFork tid: %llu\n", GetTid());
}
void ForkParentAfter(ThreadState* thr, uptr pc) { ForkAfter(thr, false); }
More information about the llvm-commits
mailing list