]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Partial fix for bz339745. Mac OS: Further progress worker queue thread support. Addit...
authorRhys Kidd <rhyskidd@gmail.com>
Mon, 26 Jan 2015 03:27:01 +0000 (03:27 +0000)
committerRhys Kidd <rhyskidd@gmail.com>
Mon, 26 Jan 2015 03:27:01 +0000 (03:27 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14888

NEWS
coregrind/m_syswrap/syswrap-amd64-darwin.c
coregrind/m_syswrap/syswrap-x86-darwin.c

diff --git a/NEWS b/NEWS
index 84eddf67d0a95ff8b781788cce2957e472373c2a..4cf2556014f361f50c66dd47efb012e1d115da3f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -56,6 +56,7 @@ where XXXXXX is the bug number as listed below.
 339442  Fix testsuite build failure on OS X 10.9
 339688  Mac-specific ASM does not support .version directive (cpuid,
         tronical and pushfpopf tests)
+339745  Valgrind crash when check Marmalade app (partial fix)
 339755  Fix known deliberate memory leak in setenv() on Mac OS X 10.9
 339780  Fix known uninitialised read in pthread_rwlock_init() on Mac OS X 10.9 
 339789  Fix none/tests/execve test on Mac OS X 10.9
index b1790bb4767aa914228e24249b4975eee2df6606..b8b886500d11140e1efa0b675412f5b68cfb83b1 100644 (file)
@@ -465,10 +465,7 @@ void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem,
       out just the relevant parts.  Hence: */
 #  if DARWIN_VERS <= DARWIN_10_7
    Bool is_reuse = reuse != 0;
-#  elif DARWIN_VERS == DARWIN_10_8 || DARWIN_VERS == DARWIN_10_9
-   Bool is_reuse = (reuse & 0x20000 /* == WQ_FLAG_THREAD_REUSE */) != 0;
-#  elif DARWIN_VERS == DARWIN_10_10
-   // XXX FIXME is this correct?
+#  elif DARWIN_VERS == DARWIN_10_8 || DARWIN_VERS == DARWIN_10_9 || DARWIN_VERS == DARWIN_10_10
    Bool is_reuse = (reuse & 0x20000 /* == WQ_FLAG_THREAD_REUSE */) != 0;
 #  else
 #    error "Unsupported Darwin version"
index b4a6f63b71f089844b8d2fd6fa5aa787499ce777..64d5358ac7fc864600d4c0bfb6c704df01885caa 100644 (file)
@@ -397,20 +397,42 @@ void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem,
       lock. */
    VG_(acquire_BigLock_LL)("wqthread_hijack");
 
+   if (0) VG_(printf)(
+             "wqthread_hijack: self %#lx, kport %#lx, "
+             "stackaddr %#lx, workitem %#lx, reuse/flags %x, sp %#lx\n",
+             self, kport, stackaddr, workitem, reuse, sp);
+
    /* Start the thread with all signals blocked.  VG_(scheduler) will
       set the mask correctly when we finally get there. */
    VG_(sigfillset)(&blockall);
    VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, NULL);
 
-   if (reuse) {
+   /* For 10.7 and earlier, |reuse| appeared to be used as a simple
+      boolean.  In 10.8 and later its name changed to |flags| and has
+      various other bits OR-d into it too, so it's necessary to fish
+      out just the relevant parts.  Hence: */
+#  if DARWIN_VERS <= DARWIN_10_7
+   Bool is_reuse = reuse != 0;
+#  elif DARWIN_VERS == DARWIN_10_8 || DARWIN_VERS == DARWIN_10_9 || DARWIN_VERS == DARWIN_10_10
+   Bool is_reuse = (reuse & 0x20000 /* == WQ_FLAG_THREAD_REUSE */) != 0;
+#  else
+#    error "Unsupported Darwin version"
+#  endif
+
+   if (is_reuse) {
 
       /* For whatever reason, tst->os_state.pthread appear to have a
          constant offset of 72 on 10.7, but zero on 10.6 and 10.5.  No
          idea why. */
 #     if DARWIN_VERS <= DARWIN_10_6
       UWord magic_delta = 0;
-#     elif DARWIN_VERS >= DARWIN_10_7
+#     elif DARWIN_VERS == DARWIN_10_7 || DARWIN_VERS == DARWIN_10_8
       UWord magic_delta = 0x48;
+#     elif DARWIN_VERS == DARWIN_10_9 || DARWIN_VERS == DARWIN_10_10
+      UWord magic_delta = 0xB0;
+#     else
+#       error "magic_delta: to be computed on new OS version"
+        // magic_delta = tst->os_state.pthread - self
 #     endif
 
       // This thread already exists; we're merely re-entering 
@@ -454,7 +476,7 @@ void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem,
    stacksize = 512*1024;  // wq stacks are always DEFAULT_STACK_SIZE
    stack = VG_PGROUNDUP(sp) - stacksize;
 
-   if (reuse) {
+   if (is_reuse) {
        // Continue V's thread back in the scheduler. 
        // The client thread is of course in another location entirely.