[TSan] Support __sanitizer_set_death_callback().

llvm-svn: 245776
This commit is contained in:
Alexey Samsonov 2015-08-22 01:07:02 +00:00
parent 0a3ac1be43
commit eb4fe7883f
3 changed files with 7 additions and 17 deletions

View File

@ -2449,7 +2449,7 @@ static void finalize(void *arg) {
// Make sure the output is not lost.
FlushStreams();
if (status)
REAL(_exit)(status);
Die();
}
static void unreachable() {

View File

@ -514,7 +514,7 @@ bool OutputReport(ThreadState *thr, const ScopedReport &srep) {
PrintReport(rep);
ctx->nreported++;
if (flags()->halt_on_error)
internal__exit(common_flags()->exitcode);
Die();
return true;
}

View File

@ -1,10 +1,7 @@
// RUN: %clangxx -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// Check __sanitizer_set_death_callback. Not all sanitizers implement it yet.
// XFAIL: tsan
#include <sanitizer/common_interface_defs.h>
#include <stdio.h>
#include <pthread.h>
volatile char *zero = 0;
@ -13,14 +10,9 @@ void Death() {
}
// CHECK: DEATH CALLBACK EXECUTED
int global[10];
char global;
volatile char *sink;
void *Thread(void *x) {
global[0]++;
return x;
}
__attribute__((noinline))
void MaybeInit(int *uninitialized) {
if (zero)
@ -37,12 +29,10 @@ int main(int argc, char **argv) {
__sanitizer_set_death_callback(Death);
MaybeInit(&uninitialized);
if (uninitialized) // trigger msan report.
global[0] = 77;
pthread_t t;
pthread_create(&t, 0, Thread, 0);
global[0]++; // trigger tsan report.
pthread_join(t, 0);
global[argc + 10]++; // trigger asan report.
global = 77;
sink = new char[100];
delete[] sink;
global = sink[0]; // use-after-free: trigger asan/tsan report.
Leak();
sink = 0;
}