NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/45327: ptrace: siginfo doesn't work with traced processes



>Number:         45327
>Category:       kern
>Synopsis:       ptrace: siginfo doesn't work with traced processes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 03 15:45:00 +0000 2011
>Originator:     Jared McNeill
>Release:        5.99.55
>Organization:
>Environment:
>Description:
When an application is being traced, siginfo data gets lost somewhere. This can 
be observed when trying to debug an application that uses aio:


$ ./aio
io_callback: sig=23 code=-3
done


$ gdb ./aio
[...]

(gdb) run
Starting program: /home/jmcneill/aio
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
waiting...
io_callback: sig=23 code=32767
assertion "info->si_code == SI_ASYNCIO" failed: file "aio.c", line 20, function 
"io_callback"

Program received signal SIGABRT, Aborted.
0xabe12df7 in aio_read () from /usr/lib/librt.so.0

>How-To-Repeat:
#include <sys/types.h>
#include <sys/signal.h>

#include <aio.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

static struct aiocb aio;
static uint8_t data[64];

int done = 0;

void
io_callback(int sig, siginfo_t *info, void *priv)
{
        printf("%s: sig=%d code=%d\n", __func__, sig, info->si_code);
        assert(info->si_code == SI_ASYNCIO);
        done = 1;
}


int
main(void)
{
        struct sigaction sa;
        int fd, error;

        fd = open("/dev/zero", O_RDONLY);
        assert(fd != -1);

        memset(&sa, 0, sizeof(sa));
        sigemptyset(&sa.sa_mask);
        sa.sa_flags = SA_RESTART|SA_SIGINFO;
        sa.sa_sigaction = io_callback;
        error = sigaction(SIGIO, &sa, NULL);
        assert(error != -1);

        memset(&aio, 0, sizeof(aio));
        aio.aio_fildes = fd;
        aio.aio_buf = data;
        aio.aio_nbytes = sizeof(data);
        aio.aio_offset = 0;
        aio.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
        aio.aio_sigevent.sigev_signo = SIGIO;
        aio.aio_sigevent.sigev_value.sival_ptr = NULL;

        error = aio_read(&aio);
        assert(error != -1);

        while (done == 0) {
                printf("waiting...\n");
                sleep(1);
        }
        printf("done\n");

        close(fd);

        return 0;
}

>Fix:



Home | Main Index | Thread Index | Old Index