summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-07-19 05:03:38 +0000
committerDerek Bruening <bruening@google.com>2016-07-19 05:03:38 +0000
commit9419737fa8542cfa5045ffc2e442aff6efe4bfe4 (patch)
tree31b59b1c20be73b3ae664a8350e13ef1c2d1d689
parent5140e748b54022684ddecba9bac61eab156c3dbe (diff)
downloadbcm5719-llvm-9419737fa8542cfa5045ffc2e442aff6efe4bfe4.tar.gz
bcm5719-llvm-9419737fa8542cfa5045ffc2e442aff6efe4bfe4.zip
[esan] Fix sideline thread flaky assert
Fixes an esan sideline thread CHECK that failed to account for the sideline thread reaching its code before the internal_clone() return value was assigned in the parent. llvm-svn: 275946
-rw-r--r--compiler-rt/lib/esan/esan_sideline_linux.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler-rt/lib/esan/esan_sideline_linux.cpp b/compiler-rt/lib/esan/esan_sideline_linux.cpp
index ba4fe62f592..d04f5909d6a 100644
--- a/compiler-rt/lib/esan/esan_sideline_linux.cpp
+++ b/compiler-rt/lib/esan/esan_sideline_linux.cpp
@@ -31,6 +31,7 @@ namespace __esan {
static const int SigAltStackSize = 4*1024;
static const int SidelineStackSize = 4*1024;
+static const uptr SidelineIdUninitialized = 1;
// FIXME: we'll need some kind of TLS (can we trust that a pthread key will
// work in our non-POSIX thread?) to access our data in our signal handler
@@ -113,6 +114,10 @@ bool SidelineThread::launchThread(SidelineFunc takeSample, void *Arg,
// We do without a guard page.
Stack = static_cast<char*>(MmapOrDie(SidelineStackSize, "SidelineStack"));
+ // We need to handle the return value from internal_clone() not having been
+ // assigned yet (for our CHECK in adjustTimer()) so we ensure this has a
+ // sentinel value.
+ SidelineId = SidelineIdUninitialized;
// By omitting CLONE_THREAD, the child is in its own thread group and will not
// receive any of the application's signals.
SidelineId = internal_clone(
@@ -151,7 +156,9 @@ bool SidelineThread::joinThread() {
// Must be called from the sideline thread itself.
bool SidelineThread::adjustTimer(u32 FreqMilliSec) {
- CHECK(internal_getpid() == SidelineId);
+ // The return value of internal_clone() may not have been assigned yet:
+ CHECK(internal_getpid() == SidelineId ||
+ SidelineId == SidelineIdUninitialized);
Freq = FreqMilliSec;
struct itimerval TimerVal;
TimerVal.it_interval.tv_sec = (time_t) Freq / 1000;
OpenPOWER on IntegriCloud