SysV shmdt fails with EINVAL in a fork child

Abierto
#490 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
73/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c, macos

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
C
Estrellas
287
Forks
33
Merge medio
2 d 17 h
PR fusionados (30 d)
18

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de sysprog21/elfuse

Todos los issues de sysprog21/elfuse

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.