I've found an issue where the parallel CGNS library function cgp_open() causes a runtime error (free(): invalid pointer) on a call to free an MPI_Win object with MPI_Win_free. The issue seems to be with cgp_open() rather than cgp_close(), as it still occurs if cgp_close() is commented out. The error causes the program to abort early. I've attached a minimum working example to demonstrate this.
Valgrind produces the following message if the test code is run as "mpirun -np 1 valgrind ./test":
==20955== Invalid free() / delete / delete / realloc()
==20955== at 0x4C27D4E: free (vg_replace_malloc.c:427)
==20955== by 0xD401CA0: mca_pml_ob1_recv_request_free (in /home/dwille/.deps/openmpi-2.0.0/lib/openmpi/mca_pml_ob1.so)
==20955== by 0xE45A11D: ompi_osc_pt2pt_free (in /home/dwille/.deps/openmpi-2.0.0/lib/openmpi/mca_osc_pt2pt.so)
==20955== by 0x58A303F: ompi_win_free (in /home/dwille/.deps/openmpi-2.0.0/lib/libmpi.so.20.0.0)
==20955== by 0x58D6497: PMPI_Win_free (in /home/dwille/.deps/openmpi-2.0.0/lib/libmpi.so.20.0.0)
==20955== by 0x400C50: main (test-error.c:39)
==20955== Address 0x5b29000 is 0 bytes inside data symbol "ompi_mpi_byte"
The error does not occur if:
– Both the cgp_open() and cgp_close() functions are commented out
– Both cgp_open() and cgp_close() are replaced with cg_open() and cg_close(), respectively
– Both MPI_Win_free() and MPI_Finalize() are commented out
I marked this as "major" since there does not seem to be a way around this except to not clean up the memory, which isn't a very good solution.
test-error.c – minimum working example
Makefile – makefile to compile (if given MPI, HDF5, and CGNS directories)
cgnsBuild.defs – cgns build parameters
libhdf5.settings – hdf5 build parameters
ompi-info.txt – result of ompi_info binary command
Open MPI 2.0.0