[PATCH] D47448: [Asan] Attempt to fix for FreeBSD
David CARLIER via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 28 03:42:06 PDT 2018
devnexen created this revision.
devnexen added reviewers: krytarowski, emaste, dim.
Herald added subscribers: Sanitizers, llvm-commits, kubamracek.
After several different approaches, asan hangs at AsanTSDInit, thus choosing a similar workflow as fuschia for example. Keeping the current workflow for other oses.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D47448
Files:
lib/asan/asan_posix.cc
Index: lib/asan/asan_posix.cc
===================================================================
--- lib/asan/asan_posix.cc
+++ lib/asan/asan_posix.cc
@@ -40,31 +40,60 @@
// ---------------------- TSD ---------------- {{{1
+#if !SANITIZER_FREEBSD
static pthread_key_t tsd_key;
+#else
+struct Tsd {
+ void *data;
+ void (*destructor)(void *tsd);
+ Tsd() : data(nullptr), destructor(nullptr) {}
+ ~Tsd() {
+ if (destructor)
+ destructor(data);
+ }
+};
+
+static thread_local Tsd _tsd;
+#endif
static bool tsd_key_inited = false;
void AsanTSDInit(void (*destructor)(void *tsd)) {
CHECK(!tsd_key_inited);
tsd_key_inited = true;
+#if !SANITIZER_FREEBSD
CHECK_EQ(0, pthread_key_create(&tsd_key, destructor));
+#else
+ CHECK_EQ(destructor, &PlatformTSDDtor);
+ _tsd.destructor = destructor;
+#endif
}
void *AsanTSDGet() {
CHECK(tsd_key_inited);
+#if !SANITIZER_FREEBSD
return pthread_getspecific(tsd_key);
+#else
+ return _tsd.data;
+#endif
}
void AsanTSDSet(void *tsd) {
CHECK(tsd_key_inited);
+#if !SANITIZER_FREEBSD
pthread_setspecific(tsd_key, tsd);
+#else
+ _tsd.data = tsd;
+#endif
}
void PlatformTSDDtor(void *tsd) {
+#if !SANITIZER_FREEBSD
AsanThreadContext *context = (AsanThreadContext*)tsd;
if (context->destructor_iterations > 1) {
context->destructor_iterations--;
CHECK_EQ(0, pthread_setspecific(tsd_key, tsd));
return;
}
+#endif
AsanThread::TSDDtor(tsd);
}
} // namespace __asan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47448.148800.patch
Type: text/x-patch
Size: 1476 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180528/9347e5b2/attachment.bin>
More information about the llvm-commits
mailing list