1f061d
commit 18b3ffc1a8dc951d8a8cdb076e7e30aafc216571
1f061d
Author: philippe <philippe@a5019735-40e9-0310-863c-91ae7b9d1cf9>
1f061d
Date:   Sat Nov 19 14:54:44 2016 +0000
1f061d
1f061d
    Fix 372504  Hanging on exit_group
1f061d
    
1f061d
    Note that it is unclear if the PRE syscall for rt_sigsuspend
1f061d
    is properly setting up a temporary mask in the thread state
1f061d
    tmp_sig_mask:  if an handler is called while a thread is
1f061d
    calling sigsuspend, the mask during the handler run must be
1f061d
    the temporary mask set by sigsuspend.
1f061d
    It is not clear if/where the valgrind sigframe builder/handler
1f061d
    sets the tmp_sig_mask to the value as expected by the user
1f061d
    (i.e. the value of the temporary mask which was given to
1f061d
    the sigsuspend syscall)
1f061d
    
1f061d
    
1f061d
    
1f061d
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16141 a5019735-40e9-0310-863c-91ae7b9d1cf9
1f061d
1f061d
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
1f061d
index 1dcb95d..fda8dd1 100644
1f061d
--- a/coregrind/m_syswrap/syswrap-linux.c
1f061d
+++ b/coregrind/m_syswrap/syswrap-linux.c
1f061d
@@ -3558,6 +3558,12 @@ PRE(sys_rt_sigsuspend)
1f061d
    PRE_REG_READ2(int, "rt_sigsuspend", vki_sigset_t *, mask, vki_size_t, size)
1f061d
    if (ARG1 != (Addr)NULL) {
1f061d
       PRE_MEM_READ( "rt_sigsuspend(mask)", ARG1, sizeof(vki_sigset_t) );
1f061d
+      VG_(sigdelset)((vki_sigset_t*)ARG1, VG_SIGVGKILL); 
1f061d
+      /* We cannot mask VG_SIGVGKILL, as otherwise this thread would not
1f061d
+         be killable by VG_(nuke_all_threads_except).
1f061d
+         We thus silently ignore the user request to mask this signal.
1f061d
+         Note that this is similar to what is done for e.g.
1f061d
+         sigprocmask (see m_signals.c calculate_SKSS_from_SCSS).  */
1f061d
    }
1f061d
 }
1f061d
 
1f061d
diff --git a/coregrind/pub_core_threadstate.h b/coregrind/pub_core_threadstate.h
1f061d
index 861f233..f3d956c 100644
1f061d
--- a/coregrind/pub_core_threadstate.h
1f061d
+++ b/coregrind/pub_core_threadstate.h
1f061d
@@ -354,7 +354,9 @@ typedef struct {
1f061d
       different values is during the execution of a sigsuspend, where
1f061d
       tmp_sig_mask is the temporary mask which sigsuspend installs.
1f061d
       It is only consulted to compute the signal mask applied to a
1f061d
-      signal handler. */
1f061d
+      signal handler. 
1f061d
+      PW Nov 2016 : it is not clear if and where this tmp_sig_mask
1f061d
+      is set when an handler runs "inside" a sigsuspend. */
1f061d
    vki_sigset_t tmp_sig_mask;
1f061d
 
1f061d
    /* A little signal queue for signals we can't get the kernel to