I have a mature application (processing oceanographic data), it reads input data files (several) opens an HDF5 file, writes to it, closes it, closes the input files, reopens the output file, does some post-processing, writing the results back into the output file, closes it.
I recently added a new input file format, netCDF4, which is of course HDF5 under the hood. On processing these files I now get a segfault at exit.
Program terminated with signal SIGSEGV, Segmentation fault. #0 0x000055b4a1b46318 in ?? () (gdb) bt #0 0x000055b4a1b46318 in ?? () #1 0x00007f2d73f14755 in H5E_dump_api_stack () from /usr/lib/x86_64-linux-gnu/libhdf5_serial.so.103 #2 0x00007f2d73f11dd0 in H5Eget_auto2 () from /usr/lib/x86_64-linux-gnu/libhdf5_serial.so.103 #3 0x00007f2d73e7f4b4 in H5_term_library () from /usr/lib/x86_64-linux-gnu/libhdf5_serial.so.103 #4 0x00007f2d73c9a8a7 in __run_exit_handlers (status=0, listp=0x7f2d73e40718 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108 #5 0x00007f2d73c9aa60 in __GI_exit (status=<optimised out>) at exit.c:139 #6 0x00007f2d73c7808a in __libc_start_main (main=0x55b49fa2e4d0 <main>, argc=8, argv=0x7ffd917950b8, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7ffd917950a8) at ../csu/libc-start.c:342 #7 0x000055b49fa2e8be in _start ()
Processing any other supported input file format does not generate a segfault. The HDF5 output file, which is explicitly closed, is not corrupted as HDF5, and looks to have the expected (correct) data inside it.
I did find this report of a similar issue, but the workaround suggested there is not good for me, the input format is 3rd party.
After some searching around the HDF5 docs, I tried adding
H5dont_atexit() at the very start of the program, and this seems to fix the segfaults (and I’ll take that), but leaves me a bit nervous, I’d like the
atexit hooks to run, and maybe this points to some deeper problem in my code?
If it makes a difference, this is Linux Mint Una (an Ubuntu variant), and
ldd tells that the program has shared libraries
libhdf5_serial.so.103 libhdf5_serial_hl.so.100 libnetcdf.so.15
Thanks in advance