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