info->si_code = sanitize_si_code(info->si_code);
if (VG_(clo_trace_signals))
- VG_(dmsg)("async signal handler: signal=%d, tid=%u, si_code=%d\n",
- sigNo, tid, info->si_code);
+ VG_(dmsg)("async signal handler: signal=%d, tid=%u, si_code=%d, "
+ "exitreason %s\n",
+ sigNo, tid, info->si_code,
+ VG_(name_of_VgSchedReturnCode)(tst->exitreason));
+
+ /* */
+ if (tst->exitreason == VgSrc_FatalSig)
+ resume_scheduler(tid);
/* Update thread state properly. The signal can only have been
delivered whilst we were in
);
/* (2) */
- /* Set up the thread's state to deliver a signal */
- if (!is_sig_ign(info, tid))
+ /* Set up the thread's state to deliver a signal.
+ However, if exitreason is VgSrc_FatalSig, then thread tid was
+ taken out of a syscall by VG_(nuke_all_threads_except).
+ But after the emission of VKI_SIGKILL, another (fatal) async
+ signal might be sent. In such a case, we must not handle this
+ signal, as the thread is supposed to die first.
+ => resume the scheduler for such a thread, so that the scheduler
+ can let the thread die. */
+ if (tst->exitreason != VgSrc_FatalSig
+ && !is_sig_ign(info, tid))
deliver_signal(tid, info, uc);
/* It's crucial that (1) and (2) happen in the order (1) then (2)
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
+ 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
+ that. */
+ if (VG_(clo_trace_signals))
+ VG_(dmsg)("poll_signals: not polling as thread %u is exitreason %s\n",
+ tid, VG_(name_of_VgSchedReturnCode)(tst->exitreason));
+ return;
+ }
+
/* look for all the signals this thread isn't blocking */
/* pollset = ~tst->sig_mask */
VG_(sigcomplementset)( &pollset, &tst->sig_mask );
/* If there was nothing queued, ask the kernel for a pending signal */
if (sip == NULL && VG_(sigtimedwait_zero)(&pollset, &si) > 0) {
if (VG_(clo_trace_signals))
- VG_(dmsg)("poll_signals: got signal %d for thread %u\n",
- si.si_signo, tid);
+ VG_(dmsg)("poll_signals: got signal %d for thread %u exitreason %s\n",
+ si.si_signo, tid,
+ VG_(name_of_VgSchedReturnCode)(tst->exitreason));
sip = &si;
}
if (sip != NULL) {
/* OK, something to do; deliver it */
if (VG_(clo_trace_signals))
- VG_(dmsg)("Polling found signal %d for tid %u\n", sip->si_signo, tid);
+ VG_(dmsg)("Polling found signal %d for tid %u exitreason %s\n",
+ sip->si_signo, tid,
+ VG_(name_of_VgSchedReturnCode)(tst->exitreason));
if (!is_sig_ign(sip, tid))
deliver_signal(tid, sip, NULL);
else if (VG_(clo_trace_signals))
}
if (VG_(clo_trace_signals))
- VG_(dmsg)("Max kernel-supported signal is %d\n", VG_(max_signal));
+ VG_(dmsg)("Max kernel-supported signal is %d, VG_SIGVGKILL is %d\n",
+ VG_(max_signal), VG_SIGVGKILL);
/* Our private internal signals are treated as ignored */
scss.scss_per_sig[VG_SIGVGKILL].scss_handler = VKI_SIG_IGN;
pth_rwlock.stderr.exp pth_rwlock.vgtest \
pth_stackalign.stderr.exp \
pth_stackalign.stdout.exp pth_stackalign.vgtest \
+ pth_2sig.stderr.exp pth_2sig.vgtest \
pth_term_signal.stderr.exp pth_term_signal.vgtest \
rcrl.stderr.exp rcrl.stdout.exp rcrl.vgtest \
readline1.stderr.exp readline1.stdout.exp \
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_term_signal\
+ pth_stackalign pth_2sig pth_term_signal\
rcrl readline1 \
require-text-symbol \
res_search resolv \
pth_rwlock_CFLAGS += --std=c99
endif
pth_stackalign_LDADD = -lpthread
+pth_2sig_LDADD = -lpthread
pth_term_signal_LDADD = -lpthread
res_search_LDADD = -lresolv -lpthread
resolv_CFLAGS = $(AM_CFLAGS)