Skip to content

ch4/posix: eager shm slab is leaked on MPI_Abort #8148

Open

Description

@garlick

The shared memory segment in /dev/shm is only unlinked in the finalize hook, so a process that exits through MPI_Abort() leaves it behind. A test loop here aborted a few hundred times and filled /dev/shm, after which every MPI_Init on the node died with SIGBUS in the slab setup.

MPICH main (5756de5), ch4:ofi, default Hydra, Linux aarch64:

      $ cat abort.c
      #include <mpi.h>
      int main (int argc, char **argv) { MPI_Init (&argc, &argv); MPI_Abort 
  (MPI_COMM_WORLD, 42); }
      $ mpicc -o abort abort.c
      $ ls /dev/shm | grep -c mpich_shm
      0
      $ mpiexec -n 2 ./abort
      Abort(42) on node 0 (rank 0 in comm 0): application called 
  MPI_Abort(MPI_COMM_WORLD, 42) - process 0
      Abort(42) on node 1 (rank 1 in comm 0): application called 
  MPI_Abort(MPI_COMM_WORLD, 42) - process 1
      $ ls /dev/shm | grep -c mpich_shm
      1
      $ for i in $(seq 10); do mpiexec -n 2 ./abort 2>/dev/null; done; ls 
  /dev/shm | grep -c mpich_shm
      11

The same program with MPI_Finalize() in place of MPI_Abort() leaves the count unchanged.

Activity

  1. hzhou commented on Nov 12, 2026

    @hzhou
    Collaborator

    This is a known annoyance. It is difficult to ensure shm files cleanups especially when the process aborts (and killed or segfaults). A easier way out is for some setup (e.g. the job launcher) clean up after the job finishes or run cleanups regularly. Let me know if there is other good ideas.

  2. garlick commented on Nov 12, 2026

    @garlick
    ContributorAuthor

    My thought was, since MPI is still in control before aborting, it could still clean up in this case. But I get how that doesn't completely solve the problem and sites need ways to clean up after other failures anyway (at ours, I think we have "job epilog" site scripts that do this).

    LMK if you're open to a patch. No problem if not.

  3. hzhou commented on Nov 12, 2026

    @hzhou
    Collaborator

    My thought was, since MPI is still in control before aborting

    That is true. That means we need split the finalize process into two sets: one set assumes graceful condition and another set as panic exit - clean up the best as you exit and never block or create more issue.

    LMK if you're open to a patch.

    Always. You are encouraged to shoot first then talk after :). No promises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions