https://bugs.kde.org/show_bug.cgi?id=361615
Bug ID: 361615 Summary: Inconsistent termination when an instrumented multithreaded process is terminated by signal Product: valgrind Version: 3.11 SVN Platform: Ubuntu Packages OS: Linux Status: UNCONFIRMED Severity: wishlist Priority: NOR Component: memcheck Assignee: jsew...@acm.org Reporter: earl_c...@yahoo.com The valgrind code attempts to terminate the program in a way that is consistent with the disposition of a signal that is not handled by the instrumented program. Unfortunately, the results depend upon whether the unhandled signal is received by the main thread, or another thread. Reproducible: Always Steps to Reproduce: Running the following test script (which compiles and runs the test program) illustrates the problem: ------------------------------------------------------- #!/bin/sh test() { rm -f foo.pid "$@" > foo.pid 2>/dev/null & PID=$! while [ "$(wc -l < foo.pid)" -lt 2 ] ; do sleep 1 done head -1 foo.pid kill $(tail -1 foo.pid) wait $PID echo $? } gcc -o foo foo.c -lpthread echo Plain test ./foo test ./foo x echo '' valgrind --version test valgrind ./foo test valgrind ./foo x echo '' valgrind/bin/valgrind --version test valgrind/bin/valgrind ./foo test valgrind/bin/valgrind ./foo x echo '' ------------------------------------------------------- #include <stdio.h> #include <unistd.h> #include <signal.h> #include <pthread.h> void * slavethread(void *arg) { while (1) sleep(1); } int main(int argc, char **argv) { pthread_t slave; if (argc > 1) printf("unblocked\n"); else { if (pthread_create(&slave, 0, &slavethread, 0)) return 255; sigset_t sigmask; if (sigfillset(&sigmask)) return 255; if (sigprocmask(SIG_BLOCK, &sigmask, 0)) return 255; printf("blocked\n"); } printf("%d\n", getpid()); fflush(stdout); while (1) sleep(1); return 0; } Actual Results: $ sh foo.sh Plain blocked 143 unblocked 143 valgrind-3.10.0.SVN blocked 137 unblocked 143 valgrind-3.11.0 blocked 137 unblocked 143 Expected Results: Ideally, all the test cases should show: -------------------- blocked 143 unblocked 143 -------------------- In the absence of that, the exit codes between the blocked and unblocked cases should be the same (and not show 137 in the blocked case, and 143 in the unblocked case). -- You are receiving this mail because: You are watching all bug changes.