-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Fixes google/sanitizers#858 Reviewers: eugenis, dvyukov Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D38019 llvm-svn=313835
- Loading branch information
1 parent
0a6c8c2
commit c27837f
Showing
2 changed files
with
67 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
compiler-rt/test/asan/TestCases/Posix/concurrent_overflow.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: %clangxx_asan -O0 -w %s -o %t && not %run %t 2>&1 | FileCheck %s | ||
|
||
// Checks that concurrent reports will not trigger false "nested bug" reports. | ||
// Regression test for https://github.com/google/sanitizers/issues/858 | ||
|
||
#include <pthread.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
static void *start_routine(void *arg) { | ||
volatile int *counter = (volatile int *)arg; | ||
char buf[8]; | ||
__atomic_sub_fetch(counter, 1, __ATOMIC_SEQ_CST); | ||
while (*counter) | ||
; | ||
buf[0] = buf[9]; | ||
return 0; | ||
} | ||
|
||
int main(void) { | ||
const int n_threads = 8; | ||
int i, counter = n_threads; | ||
pthread_t thread; | ||
|
||
for (i = 0; i < n_threads; ++i) | ||
pthread_create(&thread, NULL, &start_routine, (void *)&counter); | ||
sleep(5); | ||
return 0; | ||
} | ||
|
||
// CHECK-NOT: nested bug | ||
// CHECK: ERROR: AddressSanitizer: stack-buffer-overflow on address | ||
// CHECK: SUMMARY: AddressSanitizer: stack-buffer-overflow |