[sanitizer] VReport BeforeFork/AfterFork (#111900)
Forks are common suspects for unusual sanitizer behavior. It can be handy to see them without rebuild.
This commit is contained in:
parent
b3554265f2
commit
36bd9aebc4
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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() {
|
||||
|
@ -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); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user