From e2046a7652fef6cd73b1ceaea58c23625916024d Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Thu, 22 Jul 2010 08:59:07 +0000 Subject: [PATCH] pthread_hijack: start the new thread with all signals blocked, as with the x86-darwin version. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11224 --- coregrind/m_syswrap/syswrap-amd64-darwin.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/coregrind/m_syswrap/syswrap-amd64-darwin.c b/coregrind/m_syswrap/syswrap-amd64-darwin.c index 27422e51d1..1057bb1084 100644 --- a/coregrind/m_syswrap/syswrap-amd64-darwin.c +++ b/coregrind/m_syswrap/syswrap-amd64-darwin.c @@ -288,6 +288,7 @@ asm( void pthread_hijack(Addr self, Addr kport, Addr func, Addr func_arg, Addr stacksize, Addr flags, Addr sp) { + vki_sigset_t blockall; ThreadState *tst = (ThreadState *)func_arg; VexGuestAMD64State *vex = &tst->arch.vex; @@ -297,6 +298,11 @@ void pthread_hijack(Addr self, Addr kport, Addr func, Addr func_arg, // The parent thread holds V's lock on our behalf. semaphore_wait(tst->os_state.child_go); + /* 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); + // Set thread's registers // Do this FIRST because some code below tries to collect a backtrace, // which requires valid register data. @@ -339,6 +345,10 @@ void pthread_hijack(Addr self, Addr kport, Addr func, Addr func_arg, } ML_(sync_mappings)("after", "pthread_hijack", 0); + // DDD: should this be here rather than in POST(sys_bsdthread_create)? + // But we don't have ptid here... + //VG_TRACK ( pre_thread_ll_create, ptid, tst->tid ); + // Tell parent thread's POST(sys_bsdthread_create) that we're done // initializing registers and mapping memory. semaphore_signal(tst->os_state.child_done); @@ -364,8 +374,7 @@ asm( ); -/* - wqthread note: The kernel may create or destroy pthreads in the +/* wqthread note: The kernel may create or destroy pthreads in the wqthread pool at any time with no userspace interaction, and wqthread_start may be entered at any time with no userspace interaction. -- 2.47.2