Skip to content

Commit

Permalink
Prevent a race condition
Browse files Browse the repository at this point in the history
Summary:
When capturing JS stack traces for dApp loom, there is possibly a race condition that we try to stop the profiler from one thread, while the JS profiler from anther thread is trying to collect JS stack trace. When the app crashed, this is the crash report: P538093527

The fix here is to never collect stack trace if the profiler is already stopped.

Reviewed By: jpporto

Differential Revision: D40356058

fbshipit-source-id: ee54bf6d661a4e480c02eff45f2ea4d69c4d85e2
  • Loading branch information
Xida Chen authored and facebook-github-bot committed Oct 14, 2022
1 parent 6d7a3e8 commit 030381f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/VM/Profiler/SamplingProfilerPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,9 @@ void SamplingProfiler::collectStackForLoomCommon(
uint16_t max_depth,
void *profiler) {
auto profilerInstance = GlobalProfiler::get();
if (!profilerInstance->enabled()) {
return FBLoomStackCollectionRetcode::NO_STACK_FOR_THREAD;
}
auto *localProfiler = reinterpret_cast<SamplingProfiler *>(profiler);
std::lock_guard<std::mutex> lk(localProfiler->runtimeDataLock_);

Expand Down

0 comments on commit 030381f

Please sign in to comment.