From: Julian Seward Date: Fri, 30 Sep 2011 07:05:17 +0000 (+0000) Subject: Make wqthread_hijack not assert on x86-darwin. Same hack as X-Git-Tag: svn/VALGRIND_3_7_0~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9272b8d94737e62bb4f6bd8fce9eec7dc2496e94;p=thirdparty%2Fvalgrind.git Make wqthread_hijack not assert on x86-darwin. Same hack as for the 64-bit case. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12073 --- diff --git a/coregrind/m_syswrap/syswrap-x86-darwin.c b/coregrind/m_syswrap/syswrap-x86-darwin.c index 108a8afd0d..737fc75b82 100644 --- a/coregrind/m_syswrap/syswrap-x86-darwin.c +++ b/coregrind/m_syswrap/syswrap-x86-darwin.c @@ -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.