-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[sanitizer] VReport BeforeFork/AfterFork #111900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vitalybuka
merged 4 commits into
main
from
users/vitalybuka/spr/sanitizer-vreport-beforeforkafterfork
Oct 10, 2024
Merged
[sanitizer] VReport BeforeFork/AfterFork #111900
vitalybuka
merged 4 commits into
main
from
users/vitalybuka/spr/sanitizer-vreport-beforeforkafterfork
Oct 10, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
Member
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesForks are common suspects for unusual sanitizer behavior. Full diff: https://github.com/llvm/llvm-project/pull/111900.diff 6 Files Affected:
diff --git a/compiler-rt/lib/asan/asan_posix.cpp b/compiler-rt/lib/asan/asan_posix.cpp
index 4ee8d7d399e95c..4a134cbecd2532 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: %d\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: %d\n", GetTid());
}
void InstallAtForkHandler() {
diff --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 03147a79ed6543..9ce74b233e8652 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: %d\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: %d\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..8db5952270fb72 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: %d\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: %d\n", GetTid());
}
void HwasanInstallAtForkHandler() {
diff --git a/compiler-rt/lib/lsan/lsan_posix.cpp b/compiler-rt/lib/lsan/lsan_posix.cpp
index ddd9fee07e89d2..d6fe4b4940957f 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: %d\n", GetTid());
LockGlobal();
LockThreads();
LockAllocator();
@@ -108,6 +109,7 @@ static void AfterFork(bool fork_child) {
UnlockAllocator();
UnlockThreads();
UnlockGlobal();
+ VReport(2, "AfterFork tid: %d\n", GetTid());
}
void InstallAtForkHandler() {
diff --git a/compiler-rt/lib/msan/msan_linux.cpp b/compiler-rt/lib/msan/msan_linux.cpp
index 894cf17002bbc0..c4f5893e20cf37 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: %d\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: %d\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..6f6fbc53a421e0 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: %d\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: %d\n", GetTid());
}
void ForkParentAfter(ThreadState* thr, uptr pc) { ForkAfter(thr, false); }
|
fmayer
approved these changes
Oct 10, 2024
Created using spr 1.3.4 [skip ci]
DanielCChen
pushed a commit
to DanielCChen/llvm-project
that referenced
this pull request
Oct 16, 2024
Forks are common suspects for unusual sanitizer behavior. It can be handy to see them without rebuild.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler-rt:asan
Address sanitizer
compiler-rt:hwasan
Hardware-assisted address sanitizer
compiler-rt:lsan
Leak sanitizer
compiler-rt:msan
Memory sanitizer
compiler-rt:sanitizer
compiler-rt:tsan
Thread sanitizer
compiler-rt
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Forks are common suspects for unusual sanitizer behavior.
It can be handy to see them without rebuild.