]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make wqthread_hijack not assert on x86-darwin. Same hack as
authorJulian Seward <jseward@acm.org>
Fri, 30 Sep 2011 07:05:17 +0000 (07:05 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 30 Sep 2011 07:05:17 +0000 (07:05 +0000)
for the 64-bit case.

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

coregrind/m_syswrap/syswrap-x86-darwin.c

index 108a8afd0d32598b66de09ddec52ac68b4bd9dd8..737fc75b8241b97e3f79f62b6b04c809467f1cf2 100644 (file)
@@ -403,6 +403,16 @@ void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem,
    VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, NULL);
 
    if (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
+      UWord magic_delta = 0x48;
+#     endif
+
       // This thread already exists; we're merely re-entering 
       // after leaving via workq_ops(WQOPS_THREAD_RETURN). 
       // Don't allocate any V thread resources.
@@ -412,8 +422,14 @@ void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem,
       vg_assert(mach_thread_self() == kport);
 
       tst = VG_(get_ThreadState)(tid);
+
+      if (0) VG_(printf)("wqthread_hijack reuse %s: tid %d, tst %p, "
+                         "tst->os_state.pthread %#lx, self %#lx\n",
+                         tst->os_state.pthread == self ? "SAME" : "DIFF",
+                         tid, tst, tst->os_state.pthread, self);
+
       vex = &tst->arch.vex;
-      vg_assert(tst->os_state.pthread == self);
+      vg_assert(tst->os_state.pthread - magic_delta == self);
    }
    else {
       // This is a new thread.