From: Jeremy Fitzhardinge Date: Sun, 9 Nov 2003 09:51:33 +0000 (+0000) Subject: Only set the thread's status to WaitSys if we're actually waiting for X-Git-Tag: svn/VALGRIND_2_1_0~74 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=64b080887223fd9515192697a2aef5e45db589a5;p=thirdparty%2Fvalgrind.git Only set the thread's status to WaitSys if we're actually waiting for a proxyLWP to complete a syscall. Update sigaltstack test to use mmap to allocate the stack. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2016 --- diff --git a/coregrind/vg_syscalls.c b/coregrind/vg_syscalls.c index ab489a5936..91a3db5b9c 100644 --- a/coregrind/vg_syscalls.c +++ b/coregrind/vg_syscalls.c @@ -4391,10 +4391,8 @@ Bool VG_(pre_syscall) ( ThreadId tid ) comes from. */ - /* post_syscall expects us to be "waiting" even if we don't - block */ tst->syscallno = syscallno; - tst->status = VgTs_WaitSys; + vg_assert(tst->status == VgTs_Runnable); if (syscallno < MAX_SPECIAL_SYS && special_sys[syscallno].before != NULL) { sys = &special_sys[syscallno]; @@ -4454,6 +4452,11 @@ Bool VG_(pre_syscall) ( ThreadId tid ) VGP_POPCC(VgpCoreSysWrap); + /* If we're waiting on the syscall because it's in the hands of the + ProxyLWP, then set the thread state to WaitSys. */ + if (!syscall_done) + tst->status = VgTs_WaitSys; + return syscall_done; } @@ -4477,7 +4480,6 @@ void VG_(post_syscall) ( ThreadId tid ) pre_res = tst->sys_pre_res; vg_assert(syscallno != -1); /* must be a current syscall */ - vg_assert(tst->status == VgTs_WaitSys); /* should be blocked waiting */ if (syscallno < MAX_SPECIAL_SYS && special_sys[syscallno].before != NULL) { sys = &special_sys[syscallno]; @@ -4488,7 +4490,7 @@ void VG_(post_syscall) ( ThreadId tid ) sys = &bad_sys; special = True; } - + if (!VG_(is_kerror)(tst->m_eax) && sys->after != NULL) (sys->after)(tst->tid, tst); diff --git a/memcheck/tests/sigaltstack.c b/memcheck/tests/sigaltstack.c index 8f31e68ff2..c4c6549397 100644 --- a/memcheck/tests/sigaltstack.c +++ b/memcheck/tests/sigaltstack.c @@ -3,20 +3,22 @@ #include #include #include +#include void sig_handler(int sig){ int var; fprintf(stderr, "caught signal, local var is on %p\n", &var); } - int main(int argv, char** argc) { int res, i; stack_t sigstk; struct sigaction act; - sigstk.ss_sp = (char *)malloc(SIGSTKSZ); + static const int size = SIGSTKSZ; + char *stk = (char *)mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + sigstk.ss_sp = stk; - sigstk.ss_size = SIGSTKSZ; + sigstk.ss_size = size; sigstk.ss_flags = 0; fprintf(stderr, "calling sigaltstack, stack base is %p\n", sigstk.ss_sp); if (sigaltstack(&sigstk,0)<0) perror("sigaltstack");