• A
    pidfd: fix test failure due to stack overflow on some arches · 4cbd93c3
    Axel Rasmussen 提交于
    When running the pidfd_fdinfo_test on arm64, it fails for me. After some
    digging, the reason is that the child exits due to SIGBUS, because it
    overflows the 1024 byte stack we've reserved for it.
    
    To fix the issue, increase the stack size to 8192 bytes (this number is
    somewhat arbitrary, and was arrived at through experimentation -- I kept
    doubling until the failure no longer occurred).
    
    Also, let's make the issue easier to debug. wait_for_pid() returns an
    ambiguous value: it may return -1 in all of these cases:
    
    1. waitpid() itself returned -1
    2. waitpid() returned success, but we found !WIFEXITED(status).
    3. The child process exited, but it did so with a -1 exit code.
    
    There's no way for the caller to tell the difference. So, at least log
    which occurred, so the test runner can debug things.
    
    While debugging this, I found that we had !WIFEXITED(), because the
    child exited due to a signal. This seems like a reasonably common case,
    so also print out whether or not we have WIFSIGNALED(), and the
    associated WTERMSIG() (if any). This lets us see the SIGBUS I'm fixing
    clearly when it occurs.
    
    Finally, I'm suspicious of allocating the child's stack on our stack.
    man clone(2) suggests that the correct way to do this is with mmap(),
    and in particular by setting MAP_STACK. So, switch to doing it that way
    instead.
    Signed-off-by: NAxel Rasmussen <axelrasmussen@google.com>
    Acked-by: NChristian Brauner <brauner@kernel.org>
    Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
    4cbd93c3
pidfd_fdinfo_test.c 6.8 KB