sigwait() breaks when straced

From: Sanjoy Mahajan (sanjoy_at_mrao.cam.ac.uk)
Date: 07/31/05

  • Next message: David S. Miller: "Re: 2.6.13-rc3: cache flush missing from somewhere"
    To: Pavel Machek <pavel@ucw.cz>
    Date:	Sat, 30 Jul 2005 19:50:10 -0400
    
    

    Pavel Machek wrote:
    > If you think it is a linux bug, can you produce small test case doing
    > just the sigwait, and post it on l-k with big title "sigwait() breaks
    > when straced, and on suspend"?

    Here it is. I haven't tested the sigwait()+suspend lately, since
    suspend isn't working with any kernel except 2.6.11.4 and I'm chasing
    down other acpi errors in 2.6.13-*. But here's a test case for how
    sigwait() breaks when straced (see C file below). It is with 2.6.13-rc4
    on a Thinkpad 600X (Pentium III), Debian 'testing', libc
    2.3.2.

      $ gcc waiting.c -o waiting -lpthread
      $ ./waiting
      Sigwaiting...[strace my pid, which is 3359]
      [in another shell I run 'strace -p 3359', and get:]
      sigwait() returned 4, errno=0, sig=77

    In the strace window, I get

      $ strace -p 3359
      Process 3359 attached - interrupt to quit
      write(2, "sigwait() returned 4, errno=0, s"..., 39) = 39
      exit_group(4) = ?
      Process 3359 detached

    According to the man entry for sigwait:

           The !sigwait! function never returns an error.

    so the return value should not be 4 (or the docs are not right).

    Here's waiting.c:

    #include <stdio.h>
    #include <pthread.h>
    #include <signal.h>
    #include <errno.h>

    sigset_t mask;

    int main () {
      int ret, id;
      int sig = 77; /* easy to see if it gets changed */

      id = getpid();
      sigemptyset(&mask);
      fprintf (stderr, "Sigwaiting...[strace my pid, which is %d]\n", id);
      ret = sigwait(&mask, &sig);
      fprintf (stderr,
               "sigwait() returned %d, errno=%d, sig=%d\n",
               ret, errno, sig);
      return ret;
    }

    -Sanjoy

    `A society of sheep must in time beget a government of wolves.'
       - Bertrand de Jouvenal
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: David S. Miller: "Re: 2.6.13-rc3: cache flush missing from somewhere"

    Relevant Pages

    • Re: strace, holding sigacts lock over postsig(), et al.
      ... process being debugged to suspend. ... When strace calls PIOCWAIT using ... the debugging proces performs an msleepon p_stype. ... the parent strace process will wait forever for the child to hit ...
      (freebsd-current)
    • Re: 2.4.23 SMP: kernel BUG at mmap.c
      ... I also managed to capture ls segfaulting. ... The strace produced 59 lines: ... iris:~# cat asdf ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • infinite loop? with mmap, nfs, pwrite, O_DIRECT
      ... unkillable state*, and makes the system load consume an entire CPU. ... *the process is killable if run under strace, but the system load does not drop when the strace is ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: infinite loop? with mmap, nfs, pwrite, O_DIRECT
      ... > *the process is killable if run under strace, but the system load does not drop when the strace is ... > Pass this the name of a target file on an NFS mount. ... have you tried this test on other local and remote file system types? ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Re 2.6.0-test2-mm4 (pppd problem)
      ... Don't worry about that. ... I thought making a strace -f pppd of both a working kernel ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)