SysV shmdt fails with EINVAL in a fork child
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 73/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c, macos
- Domain
- operating-systems
Research direction
Start in src/syscall/sysvipc.c and trace how the attach table is updated during fork and consulted by shmdt. Compare the two approaches mentioned in the #485 review: carrying active attaches in fork state or falling back to the region table. Reproduce the issue with the fork-child shmdt in step 14 of data_child in tests/test-rlimit-mem.c; done means the child detaches successfully and the existing parent detach still succeeds.
Written by the indexing model from the issue text.
Description
A fork child cannot detach a SysV shm attach it inherited. The attach table in src/syscall/sysvipc.c is process-local, and the fork child does not rebuild it, so the child's shmdt finds no entry and fails with EINVAL.
Probe: the parent attaches a 2 MiB segment, forks, and the child calls shmdt on it.
child shmdt |
parent shmdt |
|
|---|---|---|
| Linux 6.12 | 0 | 0 |
elfuse on 170b5df |
-1 EINVAL | 0 |
| elfuse on #485 | -1 EINVAL | 0 |
Since #485 the child shares the attach with the parent (it was a private copy before), and the attach counts toward RLIMIT_AS, so the mapping the child cannot detach stays counted against the child's limit.
Two possible fixes, from the review on #485: carry the active attaches over in the fork state, or fall back to the region table in shmdt. A shmdt in the fork child of step 14 of data_child in tests/test-rlimit-mem.c would cover it.
Refs #485
- Dominant language
- C
- Stars
- 287
- Forks
- 33
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 18
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sysprog21/elfuse
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 2 days
All issues in sysprog21/elfuse
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libreswan/libreswan#3185 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
llvm:instcombine
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
llvm/llvm-project#246503 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day