[PATCH] [Tsan] Do not sanitize memset() and other functions during initialization
Viktor Kutuzov
vkutuzov at accesssoftek.com
Thu Mar 26 02:30:49 PDT 2015
Updated as suggested in http://reviews.llvm.org/D8543#inline-69954.
> Is this fix testable? or is it covered by existing tests?
This fix resolves mass failures on FreeBSD 11, see the "alignment != 0" lines at:
http://lab.llvm.org:8011/builders/sanitizer_x86_64-freebsd/builds/4831/steps/make-check-tsan/logs/stdio
http://reviews.llvm.org/D8544
Files:
lib/tsan/rtl/tsan_interceptors.cc
Index: lib/tsan/rtl/tsan_interceptors.cc
===================================================================
--- lib/tsan/rtl/tsan_interceptors.cc
+++ lib/tsan/rtl/tsan_interceptors.cc
@@ -156,6 +156,9 @@
const int SIG_SETMASK = 2;
#endif
+#define COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED \
+ (!cur_thread()->is_inited)
+
namespace std {
struct nothrow_t {};
} // namespace std
@@ -663,14 +666,17 @@
}
TSAN_INTERCEPTOR(void*, memset, void *dst, int v, uptr size) {
- SCOPED_TSAN_INTERCEPTOR(memset, dst, v, size);
- MemoryAccessRange(thr, pc, (uptr)dst, size, true);
+ // On FreeBSD we get here from libthr internals on thread initialization.
+ if (!COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) {
+ SCOPED_TSAN_INTERCEPTOR(memset, dst, v, size);
+ MemoryAccessRange(thr, pc, (uptr)dst, size, true);
+ }
return internal_memset(dst, v, size);
}
TSAN_INTERCEPTOR(void*, memcpy, void *dst, const void *src, uptr size) {
// On FreeBSD we get here from libthr internals on thread initialization.
- if (cur_thread()->is_inited) {
+ if (!COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED) {
SCOPED_TSAN_INTERCEPTOR(memcpy, dst, src, size);
MemoryAccessRange(thr, pc, (uptr)dst, size, true);
MemoryAccessRange(thr, pc, (uptr)src, size, false);
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8544.22702.patch
Type: text/x-patch
Size: 1277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150326/f3553ef2/attachment.bin>
More information about the llvm-commits
mailing list