|
From: <sv...@va...> - 2009-04-01 16:17:09
|
Author: sewardj
Date: 2009-04-01 17:17:01 +0100 (Wed, 01 Apr 2009)
New Revision: 9506
Log:
On Darwin, __NR_sigprocmask appears to affect the entire process,
not just this thread. Hence need to use __NR___pthread_sigmask
instead. Failure to do this causes V's threads to run with
unduly permissive signal masks (normally threads run with all
except synch signals blocked), and this causes async_sighandler
to assert because async signals (eg ^C) to be delivered
unexpectedly.
Also: VG_(kill): pass 3rd arg of 1 on Darwin -- requests posix
compliance, probably unnecessary, but who knows.
Modified:
branches/DARWIN/coregrind/m_libcsignal.c
branches/DARWIN/coregrind/m_syswrap/syscall-amd64-darwin.S
branches/DARWIN/coregrind/m_syswrap/syscall-x86-darwin.S
Modified: branches/DARWIN/coregrind/m_libcsignal.c
===================================================================
--- branches/DARWIN/coregrind/m_libcsignal.c 2009-03-31 14:30:39 UTC (rev 9505)
+++ branches/DARWIN/coregrind/m_libcsignal.c 2009-04-01 16:17:01 UTC (rev 9506)
@@ -176,6 +176,7 @@
*/
Int VG_(sigprocmask)( Int how, const vki_sigset_t* set, vki_sigset_t* oldset)
{
+# if defined(VGO_linux) || defined(VGO_aix5)
# if defined(__NR_rt_sigprocmask)
SysRes res = VG_(do_syscall4)(__NR_rt_sigprocmask,
how, (UWord)set, (UWord)oldset,
@@ -184,6 +185,16 @@
SysRes res = VG_(do_syscall3)(__NR_sigprocmask,
how, (UWord)set, (UWord)oldset);
# endif
+
+# elif defined(VGO_darwin)
+ /* On Darwin, __NR_sigprocmask appears to affect the entire
+ process, not just this thread. Hence need to use
+ __NR___pthread_sigmask instead. */
+ SysRes res = VG_(do_syscall3)(__NR___pthread_sigmask,
+ how, (UWord)set, (UWord)oldset);
+# else
+# error "Unknown OS"
+# endif
return sr_isError(res) ? -1 : 0;
}
@@ -288,7 +299,14 @@
Int VG_(kill)( Int pid, Int signo )
{
+# if defined(VGO_linux) || defined(VGO_aix5)
SysRes res = VG_(do_syscall2)(__NR_kill, pid, signo);
+# elif defined(VGO_darwin)
+ SysRes res = VG_(do_syscall3)(__NR_kill,
+ pid, signo, 1/*posix-compliant*/);
+# else
+# error "Unsupported OS"
+# endif
return sr_isError(res) ? -1 : 0;
}
Modified: branches/DARWIN/coregrind/m_syswrap/syscall-amd64-darwin.S
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/syscall-amd64-darwin.S 2009-03-31 14:30:39 UTC (rev 9505)
+++ branches/DARWIN/coregrind/m_syswrap/syscall-amd64-darwin.S 2009-04-01 16:17:01 UTC (rev 9506)
@@ -96,7 +96,7 @@
/* Set the signal mask which should be current during the syscall. */
/* GrP fixme signals
-
+ JRS fixme: use __NR___pthread_sigmask, not __NR_rt_sigprocmask
movq $__NR_rt_sigprocmask, %rax // syscall #
movq $VKI_SIG_SETMASK, %rdi // how
movq -24(%rbp), %rsi // sysmask
@@ -159,6 +159,7 @@
L_$0_4: /* Re-block signals. If eip is in [4,5), then the syscall
is complete and we needn't worry about it. */
/* GrP fixme signals
+ JRS fixme: use __NR___pthread_sigmask, not __NR_rt_sigprocmask
PUSH_di_si_dx_cx_8
movq $__NR_rt_sigprocmask, %rax // syscall #
Modified: branches/DARWIN/coregrind/m_syswrap/syscall-x86-darwin.S
===================================================================
--- branches/DARWIN/coregrind/m_syswrap/syscall-x86-darwin.S 2009-03-31 14:30:39 UTC (rev 9505)
+++ branches/DARWIN/coregrind/m_syswrap/syscall-x86-darwin.S 2009-04-01 16:17:01 UTC (rev 9506)
@@ -85,19 +85,19 @@
mov %esp, %ebp
subl $$8, %esp /* 16-byte align stack */
-L_$0_1: /* Even though we can't take a signal until the sigprocmask completes,
- start the range early.
+L_$0_1: /* Even though we can't take a signal until the
+ __pthread_sigmask completes, start the range early.
If eip is in the range [1,2), the syscall hasn't been started yet */
/* Set the signal mask which should be current during the syscall. */
- /* Set up for sigprocmask(SIG_SETMASK, sysmask, postmask) */
+ /* Set up for __pthread_sigmask(SIG_SETMASK, sysmask, postmask) */
pushl 20(%ebp)
pushl 16(%ebp)
pushl $$VKI_SIG_SETMASK
pushl $$0xcafebabe /* totally fake return address */
- movl $$__NR_sigprocmask, %eax
+ movl $$__NR___pthread_sigmask, %eax
int $$0x80 /* should be sysenter? */
- jc L_$0_7 /* sigprocmask failed */
+ jc L_$0_7 /* __pthread_sigmask failed */
addl $$16,%esp
/* Copy syscall parameters to the stack - assume no more than 8
@@ -161,14 +161,14 @@
L_$0_4: /* Re-block signals. If eip is in [4,5), then the syscall is
complete and we needn't worry about it. */
- /* Set up for sigprocmask(SIG_SETMASK, postmask, NULL) */
+ /* Set up for __pthread_sigmask(SIG_SETMASK, postmask, NULL) */
pushl $$0
pushl 20(%ebp)
pushl $$VKI_SIG_SETMASK
pushl $$0xcafef00d /* totally fake return address */
- movl $$__NR_sigprocmask, %eax
+ movl $$__NR___pthread_sigmask, %eax
int $$0x80 /* should be sysenter? */
- jc L_$0_7 /* sigprocmask failed */
+ jc L_$0_7 /* __pthread_sigmask failed */
addl $$16,%esp
L_$0_5: /* now safe from signals */
|