Skip to content

Commit

Permalink
Signal-based profiler/Non-Signal-based: prevent deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
gleocadie committed Jul 25, 2024
1 parent ccc791d commit 8908b83
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ StackSnapshotResultBuffer* LinuxStackFramesCollector::CollectStackSampleImplemen
// Otherwise, the CPU consumption to collect the callstack, will be accounted as "user app CPU time"
auto timerId = pThreadInfo->GetTimerId();

_plibrariesInfo->UpdateCache();

if (selfCollect)
{
// In case we are self-unwinding, we do not want to be interrupted by the signal-based profilers (walltime and cpu)
// This will crashing in libunwind (accessing a memory area which was unmapped)
// This lock is acquired by the signal-based profiler (see StackSamplerLoop->StackSamplerLoopManager)
pThreadInfo->GetStackWalkLock().Acquire();

_plibrariesInfo->UpdateCache();

on_leave
{
pThreadInfo->GetStackWalkLock().Release();
Expand Down Expand Up @@ -143,6 +143,8 @@ StackSnapshotResultBuffer* LinuxStackFramesCollector::CollectStackSampleImplemen
}
};

_plibrariesInfo->UpdateCache();

std::unique_lock<std::mutex> stackWalkInProgressLock(s_stackWalkInProgressMutex);

const auto threadId = static_cast<::pid_t>(pThreadInfo->GetOsThreadId());
Expand Down

0 comments on commit 8908b83

Please sign in to comment.