Crash on multiple file opens in HDF5 prior to 1.8.7

Hi there,

with PyTables we encountered a problem where HDF5 seg faults when opening a
file multiple times (but without doing any IO!). You can read the reported
issue here These older
versions of HDF5 are relevant because current Ubuntu LTS (long term
support) distribution ships with 1.8.4.

I managed to reduce the problem down to the following program. It opens a
file in read-only twice obtaining two handles and simply close them both in
a stacked order.

#include "stdio.h"
#include "hdf5.h"

const char *name = "/tmp/scalar.h5";

int main(int argc, char const *argv[])
printf("=============== before outer open\n");
hid_t file1_id = H5Fopen(name, H5F_ACC_RDONLY, H5P_DEFAULT);
hid_t group1_id = H5Gopen(file1_id, "/", H5P_DEFAULT);

printf("=============== before inner open\n");
hid_t file2_id = H5Fopen(name, H5F_ACC_RDONLY, H5P_DEFAULT);
hid_t group2_id = H5Gopen(file2_id, "/", H5P_DEFAULT);

printf("=============== before inner close\n");

H5L_info_t linfo;
H5Lget_info(group1_id, "/foo", &linfo, H5P_DEFAULT);

printf("=============== before outer close\n");

return 0;

HDF5 produces the following trace

=============== before outer open
H5Fopen(filename=0x10888bef2, flags=0, fapl=H5P_DEFAULT) = 16777216 (file);
H5Gopen2(loc=16777216 (file), name=0x10888bf24, gapl=H5P_DEFAULT) =
33554432 (group);
=============== before inner open
H5check_version(majnum=1, minnum=8, relnum=6) = SUCCEED;
H5Fopen(filename=0x10888bef2, flags=0, fapl=H5P_DEFAULT) = 16777217 (file);
H5Gopen2(loc=16777217 (file), name=0x10888bf24, gapl=H5P_DEFAULT) =
33554433 (group);
=============== before inner close
H5Gclose(group=33554433 (group)) = SUCCEED;
H5Fclose(file=16777217 (file)) = SUCCEED;
H5Lget_info(loc=33554432 (group), name=0x10888bf6d, linfo=0x7fff573747b0,
*Assertion failed: (f->shared), function H5AC_protect, file H5AC.c, line
Abort trap: 6

Is this a know bug? I can't reproduce it with any version after 1.8.6 but I
can't find anything relevant in the release notes.



Andrea Bedini <>