Treat a thread which is waiting to be reaped (ie one with a status
of VgTs_WaitJoiner) as non-existent for the purposes of cancellation.
This ensures that pthread_cancel returns ESRCH instead of trying to
cancel the thread, which would lead to the thread cleanup code being
run twice.
CCMAIL: 86730-done@bugs.kde.org
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2587 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c
index f603877..94adac1 100644
--- a/coregrind/vg_scheduler.c
+++ b/coregrind/vg_scheduler.c
@@ -1713,7 +1713,8 @@
vg_assert(VG_(is_valid_tid)(tid));
vg_assert(VG_(threads)[tid].status == VgTs_Runnable);
- if (!VG_(is_valid_tid)(cee)) {
+ if (!VG_(is_valid_tid)(cee) ||
+ VG_(threads)[cee].status == VgTs_WaitJoiner) {
if (VG_(clo_trace_sched)) {
VG_(sprintf)(msg_buf,
"set_cancelpend for invalid tid %d", cee);