summaryrefslogtreecommitdiff
path: root/test/msan
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2017-06-07 01:53:38 +0000
committerVitaly Buka <vitalybuka@google.com>2017-06-07 01:53:38 +0000
commit35f212efc287a7b582afcb41d86bdff7a29e7367 (patch)
treee8b427e5d37de5664d3054b77858e49e793962e7 /test/msan
parentb36ffc36dc75bbb701525be82ebe47e8879d1d45 (diff)
[tsan]: Fix GNU version of strerror_r interceptor
GNU version of strerror_r returns a result pointer that doesn't match the input buffer. The result pointer is in fact a pointer to some internal storage. TSAN was recording a write to this location, which was incorrect. Fixed https://github.com/google/sanitizers/issues/696 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/msan')
-rw-r--r--test/msan/Linux/strerror_r.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/msan/Linux/strerror_r.cc b/test/msan/Linux/strerror_r.cc
new file mode 100644
index 000000000..aec653f9c
--- /dev/null
+++ b/test/msan/Linux/strerror_r.cc
@@ -0,0 +1,18 @@
+// RUN: %clang_msan -O0 -g %s -o %t && %run %t
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+int main() {
+ char buf[1000];
+ char *res = strerror_r(EINVAL, buf, sizeof(buf));
+ assert(res);
+ volatile int z = strlen(res);
+
+ res = strerror_r(-1, buf, sizeof(buf));
+ assert(res);
+ z = strlen(res);
+
+ return 0;
+}