SysV shmdt fails with EINVAL in a fork child

Aberta
#490 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
73/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
c, macos

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug

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

Linguagem predominante
C
Estrelas
287
Forks
33
Merge médio
2d 17h
PRs com merge (30d)
18

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de sysprog21/elfuse

Todas as issues de sysprog21/elfuse

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.