Example code with a data race (see the printf) which can't be found by
ThreadSanitizer as of r2427:
===test.c===
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
pid_t child_pid = 0;
int ret = 0;
void child_handler(int signum) {
if (signum == SIGCHLD && child_pid == 0) {
printf("Whoops, PID shouldn't be 0!\n");
ret = 1;
}
}
int main(void) {
signal(SIGCHLD, child_handler);
child_pid = fork();
if (child_pid == 0) {
// in child
exit(0);
}
wait(NULL);
return ret;
}
===========
$ gcc test.c
$ while ./a.out ; do echo "PASS"; done
PASS
...
PASS
Whoops, PID shouldn't be 0!
This test case was suggested by Denis Lunev
Original issue reported on code.google.com by timurrrr on 1 Sep 2010 at 1:07
Original issue reported on code.google.com by
timurrrr
on 1 Sep 2010 at 1:07