If a process run under a valgrind does an exec then valgrind leaves it's own signal mask in place regardless of whether or not it is going to be tracing the new program. This is wrong as POSIX says that the signal mask is preserved on exec so the new program is entitled to expect the signal mask that the target program being run by valgrind had.
Created attachment 4122 [details] Patch to restore the target's signal mask on exec
Created attachment 4123 [details] Updated version of signal mask patch It was a mistake to make the restoration of the signal mask condition on the value of VG_(clo_trace_children) as we always want to do it - the new valgrind instance will then apply the mask to the traced target if we are tracing children.
Fixed in CVS. The change also needs to clear the pending signal set before setting the signal mask, so we don't get any unexpected signals before the exec. There's still a race if a new signal appears in that window.