mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-04 10:21:20 +00:00
According to the epoll_pwait(2) man page:
The sigmask argument may be specified as NULL, in which case
epoll_pwait() is equivalent to epoll_wait().
But doing that under valgrind gives:
==13887== Syscall param epoll_pwait(sigmask) points to unaddressable byte(s)
==13887== at 0x4F2B940: epoll_pwait (epoll_pwait.c:43)
==13887== by 0x400ADE: main (syscalls-2007.c:89)
==13887== Address 0x0 is not stack'd, malloc'd or (recently) free'd
This is because the sys_epoll_pwait wrapper has:
if (ARG4)
PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5, sizeof(vki_sigset_t) );
Which looks like a typo (ARG4 is timeout and ARG5 is sigmask).
This shows up with newer glibc which translates an epoll_wait call into
an epoll_pwait call with NULL sigmask.
Fix typo and add a testcase.
https://bugs.kde.org/show_bug.cgi?id=381289
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16451
95 lines
2.2 KiB
C
95 lines
2.2 KiB
C
/**
|
|
* Test program for some Linux syscalls introduced during 2006 and 2007:
|
|
* - epoll_pwait() was introduced in the 2.6.19 kernel, released in November
|
|
* 2006.
|
|
* - utimensat(), eventfd(), timerfd() and signalfd() were introduced in the
|
|
* 2.6.22 kernel, released in July 2007.
|
|
*
|
|
* See also http://bugs.kde.org/show_bug.cgi?id=160907.
|
|
*/
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include "../../config.h"
|
|
#include <fcntl.h>
|
|
#include <signal.h>
|
|
#include <stdint.h>
|
|
#if defined(HAVE_SYS_EPOLL_H)
|
|
#include <sys/epoll.h>
|
|
#endif
|
|
#if defined(HAVE_SYS_EVENTFD_H)
|
|
#include <sys/eventfd.h>
|
|
#endif
|
|
#if defined(HAVE_SYS_POLL_H)
|
|
#include <sys/poll.h>
|
|
#endif
|
|
#if defined(HAVE_SYS_SIGNALFD_H)
|
|
#include <sys/signalfd.h>
|
|
#endif
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
|
|
int main (void)
|
|
{
|
|
#if defined(HAVE_SIGNALFD) && defined(HAVE_EVENTFD) \
|
|
&& defined(HAVE_EVENTFD_READ) && defined(HAVE_PPOLL)
|
|
{
|
|
sigset_t mask;
|
|
int fd, fd2;
|
|
eventfd_t ev;
|
|
struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
|
|
struct pollfd pfd[2];
|
|
|
|
sigemptyset (&mask);
|
|
sigaddset (&mask, SIGUSR1);
|
|
fd = signalfd (-1, &mask, 0);
|
|
sigaddset (&mask, SIGUSR2);
|
|
fd = signalfd (fd, &mask, 0);
|
|
fd2 = eventfd (5, 0);
|
|
eventfd_read (fd2, &ev);
|
|
pfd[0].fd = fd;
|
|
pfd[0].events = POLLIN|POLLOUT;
|
|
pfd[1].fd = fd2;
|
|
pfd[1].events = POLLIN|POLLOUT;
|
|
ppoll (pfd, 2, &ts, &mask);
|
|
}
|
|
#endif
|
|
|
|
#if defined(HAVE_UTIMENSAT)
|
|
unlink("/tmp/valgrind-utimensat-test");
|
|
close (creat ("/tmp/valgrind-utimensat-test", S_IRUSR | S_IWUSR));
|
|
{
|
|
struct timespec ts2[2] = { [0].tv_sec = 10000000, [1].tv_sec = 20000000 };
|
|
utimensat (AT_FDCWD, "/tmp/valgrind-utimensat-test", ts2, 0);
|
|
}
|
|
unlink("/tmp/valgrind-utimensat-test");
|
|
#endif
|
|
|
|
#if defined(HAVE_EPOLL_CREATE) && defined(HAVE_EPOLL_PWAIT)
|
|
{
|
|
int fd3;
|
|
struct epoll_event evs[10];
|
|
sigset_t mask;
|
|
|
|
sigemptyset (&mask);
|
|
sigaddset (&mask, SIGUSR1);
|
|
sigaddset (&mask, SIGUSR2);
|
|
fd3 = epoll_create (10);
|
|
epoll_pwait (fd3, evs, 10, 0, &mask);
|
|
}
|
|
#endif
|
|
|
|
#if defined(HAVE_EPOLL_CREATE) && defined(HAVE_EPOLL_PWAIT)
|
|
{
|
|
int fd3;
|
|
struct epoll_event evs[10];
|
|
|
|
fd3 = epoll_create (10);
|
|
/* epoll_pwait can take a NULL sigmask. */
|
|
epoll_pwait (fd3, evs, 10, 1, NULL);
|
|
}
|
|
#endif
|
|
|
|
return 0;
|
|
}
|