[PATCH] D53805: [XRay] Guard call to postCurrentThreadFCT()
Dean Michael Berris via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 28 22:42:34 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345489: [XRay] Guard call to postCurrentThreadFCT() (authored by dberris, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D53805?vs=171450&id=171452#toc
Repository:
rL LLVM
https://reviews.llvm.org/D53805
Files:
compiler-rt/trunk/lib/xray/xray_profiling.cc
Index: compiler-rt/trunk/lib/xray/xray_profiling.cc
===================================================================
--- compiler-rt/trunk/lib/xray/xray_profiling.cc
+++ compiler-rt/trunk/lib/xray/xray_profiling.cc
@@ -133,7 +133,7 @@
if (Verbosity())
Report("profiling: No data to flush.\n");
} else {
- LogWriter* LW = LogWriter::Open();
+ LogWriter *LW = LogWriter::Open();
if (LW == nullptr) {
if (Verbosity())
Report("profiling: Failed to flush to file, dropping data.\n");
@@ -227,10 +227,15 @@
// Wait a grace period to allow threads to see that we're finalizing.
SleepForMillis(profilingFlags()->grace_period_ms);
- // We also want to make sure that the current thread's data is cleaned up,
- // if we have any.
+ // We also want to make sure that the current thread's data is cleaned up, if
+ // we have any. We need to ensure that the call to postCurrentThreadFCT() is
+ // guarded by our recursion guard.
auto &TLD = getThreadLocalData();
- postCurrentThreadFCT(TLD);
+ {
+ RecursionGuard G(ReentranceGuard);
+ if (G)
+ postCurrentThreadFCT(TLD);
+ }
// Then we force serialize the log data.
profileCollectorService::serialize();
@@ -284,7 +289,13 @@
if (TLD.Allocators == nullptr && TLD.FCT == nullptr)
return;
- postCurrentThreadFCT(TLD);
+ {
+ // If we're somehow executing this while inside a non-reentrant-friendly
+ // context, we skip attempting to post the current thread's data.
+ RecursionGuard G(ReentranceGuard);
+ if (G)
+ postCurrentThreadFCT(TLD);
+ }
});
// We also need to set up an exit handler, so that we can get the profile
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53805.171452.patch
Type: text/x-patch
Size: 1737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181029/20815251/attachment.bin>
More information about the llvm-commits
mailing list