]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix Valgrind does not support pthread_sigmask() on OS X
authorRhys Kidd <rhyskidd@gmail.com>
Sun, 12 Jul 2015 06:54:56 +0000 (06:54 +0000)
committerRhys Kidd <rhyskidd@gmail.com>
Sun, 12 Jul 2015 06:54:56 +0000 (06:54 +0000)
bz#201216

On OS X 10.10

Before:

== 592 tests, 220 stderr failures, 15 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures ==

After:

== 592 tests, 219 stderr failures, 15 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures ==

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15410

NEWS
coregrind/m_syswrap/syscall-x86-darwin.S
coregrind/m_syswrap/syswrap-darwin.c
memcheck/tests/darwin/scalar.c
memcheck/tests/darwin/scalar.stderr.exp

diff --git a/NEWS b/NEWS
index a4627598afa1ffdec687475d895be0983cb49637..b4c9f0323757ae6d5e84e9fcef069ef2207450e3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -103,6 +103,7 @@ where XXXXXX is the bug number as listed below.
 155125  avoid cutting away file:lineno after long function name
 197259  Unsupported arch_prtctl PR_SET_GS option
 201152  ppc64: Assertion in ppc32g_dirtyhelper_MFSPR_268_269
+201216  Fix Valgrind does not support pthread_sigmask() on OS X
 201435  Fix Darwin: -v does not show kernel version
 208217  "Warning: noted but unhandled ioctl 0x2000747b" on Mac OS X
 211256  Fixed an outdated comment regarding the default platform.
index 288520d093468d5ab46f23f64206dfdf9c6a1b77..73d1b2d8c35bc475aad14cf86f9464cf204e83a2 100644 (file)
@@ -89,9 +89,9 @@
        
 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 */
+           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 the signal mask which should be current during the syscall. */
         /* Set up for __pthread_sigmask(SIG_SETMASK, sysmask, postmask) */
         pushl   20(%ebp)
         pushl   16(%ebp)
index 38f823d41856823c09bde87e1217bd85051a169c..f804ade25cc2ecb516065a1687b1a76991edc3e9 100644 (file)
@@ -2142,11 +2142,45 @@ PRE(__pthread_kill)
 
 PRE(__pthread_sigmask)
 {
-   // GrP fixme
-   // JRS: arguments are identical to sigprocmask 
-   // (how, sigset_t*, sigset_t*).  Perhaps behave identically?
-   log_decaying("UNKNOWN __pthread_sigmask is unsupported.");
-   SET_STATUS_Success( 0 );
+    // arguments are identical to sigprocmask (how, sigset_t*, sigset_t*).
+    UWord arg1;
+    PRINT("__pthread_sigmask ( %ld, %#lx, %#lx )", ARG1, ARG2, ARG3);
+    PRE_REG_READ3(long, "__pthread_sigmask",
+                  int, how, vki_sigset_t *, set, vki_sigset_t *, oldset);
+    if (ARG2 != 0)
+        PRE_MEM_READ( "__pthread_sigmask(set)", ARG2, sizeof(vki_sigset_t));
+    if (ARG3 != 0)
+        PRE_MEM_WRITE( "__pthread_sigmask(oldset)", ARG3, sizeof(vki_sigset_t));
+    
+    /* Massage ARG1 ('how').  If ARG2 (the new mask) is NULL then the
+     value of 'how' is irrelevant, and it appears that Darwin's libc
+     passes zero, which is not equal to any of
+     SIG_{BLOCK,UNBLOCK,SETMASK}.  This causes
+     VG_(do_sys_sigprocmask) to complain, since it checks the 'how'
+     value independently of the other args.  Solution: in this case,
+     simply pass a valid (but irrelevant) value for 'how'. */
+    /* Also, in this case the new set is passed to the kernel by
+     reference, not value, as in some other sigmask related Darwin
+     syscalls. */
+    arg1 = ARG1;
+    if (ARG2 == 0  /* the new-set is NULL */
+        && ARG1 != VKI_SIG_BLOCK
+        && ARG1 != VKI_SIG_UNBLOCK && ARG1 != VKI_SIG_SETMASK) {
+        arg1 = VKI_SIG_SETMASK;
+    }
+    SET_STATUS_from_SysRes(
+                           VG_(do_sys_sigprocmask) ( tid, arg1, (vki_sigset_t*)ARG2,
+                                                    (vki_sigset_t*)ARG3 )
+                           );
+    
+    if (SUCCESS)
+        *flags |= SfPollAfter;
+}
+POST(__pthread_sigmask)
+{
+    vg_assert(SUCCESS);
+    if (RES == 0 && ARG3 != 0)
+        POST_MEM_WRITE( ARG3, sizeof(vki_sigset_t));
 }
 
 
index 5b8a3fb21a485b393997280b6c54d855c477de95..af4def4d32f104678ec606e206ebdacd1b4efe9c 100644 (file)
@@ -589,7 +589,9 @@ int main(void)
    GO(__NR___pthread_kill, 328, "2s 0m");
    SY(__NR___pthread_kill, x0, x0); FAIL;
 
-   // __NR___pthread_sigmask 329
+   GO(__NR___pthread_sigmask, 329, "3s 0m");
+   SY(__NR___pthread_sigmask, x0, x0, x0); SUCC;
+
    // __NR___sigwait 330
    // __NR_sigwait 330) // GrP fixme hack
    // __NR___disable_threadsignal 331
index 6278d25222dc7ddda314d0ae0cdb031521607a55..00ee89bd16b96dc03253ce59f122e3dfef989597 100644 (file)
@@ -861,6 +861,15 @@ Syscall param __pthread_kill(thread) contains uninitialised byte(s)
 Syscall param __pthread_kill(sig) contains uninitialised byte(s)
    ...
 
+-----------------------------------------------------
+x2000149(329):__NR___pthread_sigmask 3s 0m
+-----------------------------------------------------
+Syscall param __pthread_sigmask(set) contains uninitialised byte(s)
+   ...
+
+Syscall param __pthread_sigmask(oldset) contains uninitialised byte(s)
+   ...
+
 -----------------------------------------------------
 (335):           old utrace
 -----------------------------------------------------