[Bug testsuite/62060] g++.dg/tsan/cond_race.C triggers heap-use-after-free
vries at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 8 13:29:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62060
--- Comment #3 from vries at gcc dot gnu.org ---
Created attachment 33275
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33275&action=edit
script to find differences
It seems we're missing more changes:
...
$ ./find.sh
--- compiler-rt/test/tsan/cond_race.cc 2014-08-08 14:23:28.907916207 +0200
+++ devel/src/gcc/testsuite/g++.dg/tsan/cond_race.C 2014-07-28
09:45:52.277091371 +0200
@@ -6,7 +5,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
-#include <unistd.h>
struct Ctx {
pthread_mutex_t m;
@@ -33,8 +31,6 @@
while (!c->done)
pthread_cond_wait(&c->c, &c->m);
pthread_mutex_unlock(&c->m);
- // w/o this sleep, it can be reported as use-after-free
- sleep(1);
delete c;
pthread_join(th, 0);
}
--- compiler-rt/test/tsan/thread_leak2.c 2014-08-08 14:23:28.927916207 +0200
+++ devel/src/gcc/testsuite/c-c++-common/tsan/thread_leak2.c 2014-07-28
09:45:52.185091367 +0200
@@ -1,16 +1,19 @@
+
#include <pthread.h>
-#include <stdio.h>
+#include <unistd.h>
void *Thread(void *x) {
return 0;
}
int main() {
+ int i;
+ for (i = 0; i < 5; i++) {
pthread_t t;
pthread_create(&t, 0, Thread, 0);
- pthread_detach(t);
- printf("PASS\n");
+ }
+ sleep(1);
return 0;
}
--- compiler-rt/test/tsan/mutexset1.cc 2014-08-08 14:23:28.919916207 +0200
+++ devel/src/gcc/testsuite/c-c++-common/tsan/mutexset1.c 2014-07-28
16:48:55.546509594 +0200
@@ -16,7 +17,8 @@
void *Thread2(void *x) {
Global--;
- return NULL;
+
}
int main() {
@@ -34,4 +29,12 @@
pthread_join(t[0], NULL);
pthread_join(t[1], NULL);
pthread_mutex_destroy(&mtx);
+ return 0;
}
+
--- compiler-rt/test/tsan/tls_race.cc 2014-08-08 14:23:28.907916207 +0200
+++ devel/src/gcc/testsuite/c-c++-common/tsan/tls_race.c 2014-07-28
09:45:52.185091367 +0200
@@ -1,10 +1,9 @@
+
#include <pthread.h>
#include <stddef.h>
-#include <unistd.h>
void *Thread(void *a) {
- sleep(1);
*(int*)a = 43;
return 0;
}
--- compiler-rt/test/tsan/atomic_stack.cc 2014-08-08 14:23:28.995916208
+0200
+++ devel/src/gcc/testsuite/c-c++-common/tsan/atomic_stack.c 2014-07-28
09:45:52.185091367 +0200
@@ -21,9 +22,10 @@
pthread_create(&t[1], NULL, Thread2, NULL);
pthread_join(t[0], NULL);
pthread_join(t[1], NULL);
+ return 0;
}
More information about the Gcc-bugs
mailing list