Skip to content

Long file paths causing segfault #13565

@josintom-csi

Description

@josintom-csi

Hello all -

I am running into an issue with OpenMPI 5.0.6, 5.0.9 (latest) that looks like a bug in the MPI_File_open API.

If I try to open a file where the provided filename is very long (on my system it looks like anything above 262ish characters has the issue) the MPI_File_open call just segfaults immediately.

A small reproducer code is here:

#include <mpi.h>
#include <stdio.h>
#include <string>

int main (int argc, char** argv)
{

   MPI_Init(&argc, &argv);
   MPI_File shortfile;
   MPI_File longfile;
   std::string long_filename = "longfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilenamelongfilename";
   std::string short_filename = "testfile.txt";
   printf("OPENING SHORT FILE\n");
   int fopen_short_error = MPI_File_open(MPI_COMM_WORLD, short_filename.c_str(), MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &shortfile);
   printf("SHORT FILE OPENED\n");
   MPI_File_close(&shortfile);
   
   printf("OPENING LONG FILE\n");
   int fopen_long_error = MPI_File_open(MPI_COMM_WORLD, long_filename.c_str(), MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &longfile);
   printf("LONG FILE OPENED\n");
   MPI_File_close(&longfile);
 
   MPI_Finalize();
}

The output of this program is:

OPENING SHORT FILE

SHORT FILE OPENED
OPENING LONG FILE
[localhost:155795] *** Process received signal ***
[localhost:155795] Signal: Segmentation fault (11)
[localhost:155795] Signal code:  (128)
[localhost:155795] Failing at address: (nil)
Segmentation fault (core dumped)

Has anyone seen this error before? As far as I can tell this is not an issue with OpenMPI versions 4.x.x, and it is not a problem on MPICH, IntelMPI, or HPCX (which is based on OpenMPI 4.x.x). I have not tried any other MPI implementations.

Thanks,
Cooper

Posting on behalf of Cooper Burns from Convergent Science

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions