[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:
@@ -149,6 +149,7 @@ void PlatformTSDDtor(void *tsd) {
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
static void BeforeFork() {
|
static void BeforeFork() {
|
||||||
|
VReport(2, "BeforeFork tid: %llu\n", GetTid());
|
||||||
if (CAN_SANITIZE_LEAKS) {
|
if (CAN_SANITIZE_LEAKS) {
|
||||||
__lsan::LockGlobal();
|
__lsan::LockGlobal();
|
||||||
}
|
}
|
||||||
@@ -168,6 +169,7 @@ static void AfterFork(bool fork_child) {
|
|||||||
if (CAN_SANITIZE_LEAKS) {
|
if (CAN_SANITIZE_LEAKS) {
|
||||||
__lsan::UnlockGlobal();
|
__lsan::UnlockGlobal();
|
||||||
}
|
}
|
||||||
|
VReport(2, "AfterFork tid: %llu\n", GetTid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallAtForkHandler() {
|
void InstallAtForkHandler() {
|
||||||
|
|||||||
@@ -2859,6 +2859,7 @@ WRAPPER_ALIAS(__isoc99_sscanf, sscanf)
|
|||||||
WRAPPER_ALIAS(__isoc23_sscanf, sscanf)
|
WRAPPER_ALIAS(__isoc23_sscanf, sscanf)
|
||||||
|
|
||||||
static void BeforeFork() {
|
static void BeforeFork() {
|
||||||
|
VReport(2, "BeforeFork tid: %llu\n", GetTid());
|
||||||
StackDepotLockBeforeFork();
|
StackDepotLockBeforeFork();
|
||||||
ChainedOriginDepotLockBeforeFork();
|
ChainedOriginDepotLockBeforeFork();
|
||||||
}
|
}
|
||||||
@@ -2866,6 +2867,7 @@ static void BeforeFork() {
|
|||||||
static void AfterFork(bool fork_child) {
|
static void AfterFork(bool fork_child) {
|
||||||
ChainedOriginDepotUnlockAfterFork(fork_child);
|
ChainedOriginDepotUnlockAfterFork(fork_child);
|
||||||
StackDepotUnlockAfterFork(fork_child);
|
StackDepotUnlockAfterFork(fork_child);
|
||||||
|
VReport(2, "AfterFork tid: %llu\n", GetTid());
|
||||||
}
|
}
|
||||||
|
|
||||||
SANITIZER_INTERFACE_ATTRIBUTE
|
SANITIZER_INTERFACE_ATTRIBUTE
|
||||||
|
|||||||
@@ -528,6 +528,7 @@ uptr TagMemoryAligned(uptr p, uptr size, tag_t tag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void BeforeFork() {
|
static void BeforeFork() {
|
||||||
|
VReport(2, "BeforeFork tid: %llu\n", GetTid());
|
||||||
if (CAN_SANITIZE_LEAKS) {
|
if (CAN_SANITIZE_LEAKS) {
|
||||||
__lsan::LockGlobal();
|
__lsan::LockGlobal();
|
||||||
}
|
}
|
||||||
@@ -547,6 +548,7 @@ static void AfterFork(bool fork_child) {
|
|||||||
if (CAN_SANITIZE_LEAKS) {
|
if (CAN_SANITIZE_LEAKS) {
|
||||||
__lsan::UnlockGlobal();
|
__lsan::UnlockGlobal();
|
||||||
}
|
}
|
||||||
|
VReport(2, "AfterFork tid: %llu\n", GetTid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HwasanInstallAtForkHandler() {
|
void HwasanInstallAtForkHandler() {
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ void InstallAtExitCheckLeaks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void BeforeFork() {
|
static void BeforeFork() {
|
||||||
|
VReport(2, "BeforeFork tid: %llu\n", GetTid());
|
||||||
LockGlobal();
|
LockGlobal();
|
||||||
LockThreads();
|
LockThreads();
|
||||||
LockAllocator();
|
LockAllocator();
|
||||||
@@ -108,6 +109,7 @@ static void AfterFork(bool fork_child) {
|
|||||||
UnlockAllocator();
|
UnlockAllocator();
|
||||||
UnlockThreads();
|
UnlockThreads();
|
||||||
UnlockGlobal();
|
UnlockGlobal();
|
||||||
|
VReport(2, "AfterFork tid: %llu\n", GetTid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallAtForkHandler() {
|
void InstallAtForkHandler() {
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ void MsanTSDDtor(void *tsd) {
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
static void BeforeFork() {
|
static void BeforeFork() {
|
||||||
|
VReport(2, "BeforeFork tid: %llu\n", GetTid());
|
||||||
// Usually we lock ThreadRegistry, but msan does not have one.
|
// Usually we lock ThreadRegistry, but msan does not have one.
|
||||||
LockAllocator();
|
LockAllocator();
|
||||||
StackDepotLockBeforeFork();
|
StackDepotLockBeforeFork();
|
||||||
@@ -313,6 +314,7 @@ static void AfterFork(bool fork_child) {
|
|||||||
StackDepotUnlockAfterFork(fork_child);
|
StackDepotUnlockAfterFork(fork_child);
|
||||||
UnlockAllocator();
|
UnlockAllocator();
|
||||||
// Usually we unlock ThreadRegistry, but msan does not have one.
|
// Usually we unlock ThreadRegistry, but msan does not have one.
|
||||||
|
VReport(2, "AfterFork tid: %llu\n", GetTid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallAtForkHandler() {
|
void InstallAtForkHandler() {
|
||||||
|
|||||||
@@ -806,6 +806,7 @@ int Finalize(ThreadState *thr) {
|
|||||||
|
|
||||||
#if !SANITIZER_GO
|
#if !SANITIZER_GO
|
||||||
void ForkBefore(ThreadState* thr, uptr pc) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
|
void ForkBefore(ThreadState* thr, uptr pc) SANITIZER_NO_THREAD_SAFETY_ANALYSIS {
|
||||||
|
VReport(2, "BeforeFork tid: %llu\n", GetTid());
|
||||||
GlobalProcessorLock();
|
GlobalProcessorLock();
|
||||||
// Detaching from the slot makes OnUserFree skip writing to the shadow.
|
// 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.
|
// 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);
|
SlotAttachAndLock(thr);
|
||||||
SlotUnlock(thr);
|
SlotUnlock(thr);
|
||||||
GlobalProcessorUnlock();
|
GlobalProcessorUnlock();
|
||||||
|
VReport(2, "AfterFork tid: %llu\n", GetTid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForkParentAfter(ThreadState* thr, uptr pc) { ForkAfter(thr, false); }
|
void ForkParentAfter(ThreadState* thr, uptr pc) { ForkAfter(thr, false); }
|
||||||
|
|||||||
Reference in New Issue
Block a user