sys_epoll_wait/sys_epoll_pwait2 drop syscalls when 4 FDs ready for operation

Open Beginner friendly
#4,145 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, linux

Research direction

The bug is in the syscall-buffering preload code at src/preload/syscallbuf.c, around lines 2827-2828, where the return value of the epoll_wait call is compared against EINTR. Check the same pattern in the sys_epoll_pwait2 handler. Read the linked man page section on return values, then confirm the fix by recording a program that gets four ready file descriptors and checking that no syscalls are dropped. Done means the return check tests -1 and errno instead of the return value.

Written by the indexing model from the issue text.

Description

per https://www.man7.org/linux/man-pages/man2/epoll_wait.2.html

On success, epoll_wait() returns the number of file descriptors
ready for the requested I/O operation, or zero if no file
descriptor became ready during the requested timeout milliseconds.
On failure, epoll_wait() returns -1 and errno is set to indicate
the error.

https://github.com/rr-debugger/rr/blob/master/src/preload/syscallbuf.c#L2827-L2828 (and corresponding code for sys_epoll_pwait2) check the return value of the syscall against EINTR (defined to be 4). This is a bug, and drops syscalls when using rr recording.
Instead, ret should be checked against -1, and errno against EINTR.

Thanks to my AI for finding this bug 😅

Dominant language
C++
Stars
10.7k
Forks
666
Avg merge
1d 22h
Merged PRs (30d)
32

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rr-debugger/rr

All issues in rr-debugger/rr

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.