rr-debugger / rr-debugger/rr

Simplify scratch processing

Open
#374 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.7k
Forks
662
Avg merge
2d 3h
Merged PRs (30d)
2

Description

There's a lot of (rather deilcate) code in place to handle various cases around scratch-buffer management. I'd really like to simplify that if possible.

An idea that strikes me is that for syscalls like read() with unbounded buffer sizes, allocate scratch buffers on a best-effort basis, rather than all-or-none. The kernel can return as little data as it wants, so rr can take advantage of that to pass a smaller input buffer to the kernel if not enough scratch is available.

This would be unsound for syscalls with inoutparams, so it would still be possible to exhaust scratch, but those cases are so edge (deep sighandler interrupts of huge poll buffers, e.g.) I'm inclined not to care if it simplifies the code a lot.

In reality, there are certain "gentlemen's agreements" linux makes with userspace, like reads of 4096 bytes or under on files succeed or fail atomically, IIRC. And the notion of "best-effort" is horrendously hard to define for a syscall like recvmsg(). And ioctl()s and interacting with special devices ...

Contributor guide

Open the contributing guide

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.

Research direction

Start by tracing scratch-buffer management around the read(), recvmsg(), ioctl(), and poll() syscall paths. Compare how unbounded buffers and inoutparams are handled, then determine a safe simplification that preserves correctness; done means the behavior is validated for the discussed syscall cases without unsound partial handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
operating-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.