]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Only set the thread's status to WaitSys if we're actually waiting for
authorJeremy Fitzhardinge <jeremy@valgrind.org>
Sun, 9 Nov 2003 09:51:33 +0000 (09:51 +0000)
committerJeremy Fitzhardinge <jeremy@valgrind.org>
Sun, 9 Nov 2003 09:51:33 +0000 (09:51 +0000)
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

coregrind/vg_syscalls.c
memcheck/tests/sigaltstack.c

index ab489a59367450b9f4e2c1cdb5d730aec84fb155..91a3db5b9c9399b57ce0d0e5714b05c178b9b62b 100644 (file)
@@ -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);
 
index 8f31e68ff23f6b9a76d992cbe66ba9ea86c99112..c4c65493970a3f653a6cf4aeaa8ce51e47de0833 100644 (file)
@@ -3,20 +3,22 @@
 #include <stdio.h>
 #include <malloc.h>
 #include <signal.h>
+#include <sys/mman.h>
 
 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");