/none/tests/pth_simple_mutex
/none/tests/pth_simple_threads
/none/tests/pth_specific
+/none/tests/pth_self_kill
/none/tests/pth_stackalign
/none/tests/pth_term_signal
/none/tests/pth_yield
408091 Missing pkey syscalls
408414 Add support for missing for preadv2 and pwritev2 syscalls
404406 s390x: z14 miscellaneous instructions not implemented
+409141 Valgrind hangs when SIGKILLed
+409367 exit_group() after signal to thread waiting in futex() causes hangs
+
n-i-bz Fix minor one time leaks in dhat.
n-i-bz Add --run-cxx-freeres=no in outer args to avoid inner crashes.
n-i-bz Add support for the Linux io_uring system calls
sigNo, tid, info->si_code,
VG_(name_of_VgSchedReturnCode)(tst->exitreason));
- /* */
- if (tst->exitreason == VgSrc_FatalSig)
+ /* See similar logic in VG_(poll_signals). */
+ if (tst->exitreason != VgSrc_None)
resume_scheduler(tid);
/* Update thread state properly. The signal can only have been
ThreadState *tst = VG_(get_ThreadState)(tid);
vki_sigset_t saved_mask;
- if (tst->exitreason == VgSrc_FatalSig) {
- /* This task has been requested to die due to a fatal signal
- received by the process. So, we cannot poll new signals,
- as we are supposed to die asap. If we would poll and deliver
+ if (tst->exitreason != VgSrc_None ) {
+ /* This task has been requested to die (e.g. due to a fatal signal
+ received by the process, or because of a call to exit syscall).
+ So, we cannot poll new signals, as we are supposed to die asap.
+ If we would poll and deliver
a new (maybe fatal) signal, this could cause a deadlock, as
this thread would believe it has to terminate the other threads
and wait for them to die, while we already have a thread doing
if (tgid != -1 && tst->os_state.threadgroup != tgid)
return False; /* not the right thread group */
- /* Check to see that the target isn't already exiting. */
- if (!VG_(is_exiting)(tid)) {
- if (VG_(clo_trace_signals))
- VG_(message)(Vg_DebugMsg,
- "Thread %u being killed with SIGKILL\n",
- tst->tid);
-
- tst->exitreason = VgSrc_FatalSig;
- tst->os_state.fatalsig = VKI_SIGKILL;
-
- if (!VG_(is_running_thread)(tid))
- VG_(get_thread_out_of_syscall)(tid);
- }
-
+ /* Fatal SIGKILL sent to one of our threads.
+ "Handle" the signal ourselves, as trying to have tid
+ handling the signal causes termination problems (see #409367
+ and #409141).
+ Moreover, as a process cannot do anything when receiving SIGKILL,
+ it is not particularly crucial that "tid" does the work to
+ terminate the process. */
+
+ if (VG_(clo_trace_signals))
+ VG_(message)(Vg_DebugMsg,
+ "Thread %u %s being killed with SIGKILL, running tid: %u\n",
+ tst->tid, VG_(name_of_ThreadStatus) (tst->status), VG_(running_tid));
+
+ if (!VG_(is_running_thread)(tid))
+ tst = VG_(get_ThreadState)(VG_(running_tid));
+ VG_(nuke_all_threads_except) (VG_(running_tid), VgSrc_FatalSig);
+ VG_(reap_threads)(VG_(running_tid));
+ tst->exitreason = VgSrc_FatalSig;
+ tst->os_state.fatalsig = VKI_SIGKILL;
+
return True;
}
pth_mutexspeed.stdout.exp pth_mutexspeed.vgtest \
pth_once.stderr.exp pth_once.stdout.exp pth_once.vgtest \
pth_rwlock.stderr.exp pth_rwlock.vgtest \
+ pth_self_kill_9.stderr.exp pth_self_kill_9.vgtest \
+ pth_self_kill_15_other.stderr.exp pth_self_kill_15_other.vgtest \
pth_stackalign.stderr.exp \
pth_stackalign.stdout.exp pth_stackalign.vgtest \
pth_2sig.stderr.exp-linux pth_2sig.stderr.exp-solaris pth_2sig.vgtest \
pselect_sigmask_null \
pth_atfork1 pth_blockedsig pth_cancel1 pth_cancel2 pth_cvsimple \
pth_empty pth_exit pth_exit2 pth_mutexspeed pth_once pth_rwlock \
- pth_stackalign pth_2sig pth_term_signal\
+ pth_self_kill pth_stackalign pth_2sig pth_term_signal\
rcrl readline1 \
require-text-symbol \
res_search resolv \
pth_once_LDADD = -lpthread
pth_rwlock_LDADD = -lpthread
pth_rwlock_CFLAGS = $(AM_CFLAGS)
+pth_self_kill_LDADD = -lpthread
pth_stackalign_LDADD = -lpthread
pth_2sig_LDADD = -lpthread
pth_term_signal_LDADD = -lpthread
--- /dev/null
+#include <signal.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* This reproduces bugs 409141 and 409367.
+ valgrind ./pth_self_kill 9 was hanging.
+
+ valgrind ./pth_self_kill 15 killotherthread was looping.
+*/
+
+void *t(void *p)
+{
+ sleep (200);
+ printf ("error: supposed to die without printing this\n");
+ exit (5);
+ return NULL;
+}
+
+int main(int argc, char **argv)
+{
+ pthread_t thr;
+
+ if (argc <= 1)
+ {
+ printf
+ ("usage: pth_self_kill SIGNALNR [killotherthread] [sleepafterkill]\n");
+ exit (1);
+ }
+
+ int s = atoi(argv[1]);
+
+ pthread_create(&thr, NULL, t, NULL);
+ sleep (1);
+ if (argc > 2)
+ {
+ pthread_kill(thr, s);
+ if (argc > 3)
+ sleep (2);
+ }
+ else
+ raise(s);
+}
--- /dev/null
+prog: pth_self_kill
+args: 15 killotherthread
+vgopts: -q
--- /dev/null
+prog: pth_self_kill
+args: 9
+vgopts: -q