pelahi / VELOCIraptor-STF

Galaxy/(sub)Halo finder for N-body simulations
MIT License
19 stars 26 forks source link

Fix for segfault when HDF5 attribute has unexpected type #37

Closed jchelly closed 5 years ago

jchelly commented 5 years ago

I encountered this problem trying to run velociraptor on a swift snapshot where NumPart_ThisFile is stored as a 64 bit integer. The code reads attributes from the input HDF5 snapshot using H5Aread, which takes a parameter mem_type_id. This should be the type of the variable in memory but the code passes in the type of the data in the file instead. This causes a segfault if they don't match.

This PR modifies the code to find the data type in memory using the overloaded hdf5_type() function and pass that to H5Aread. If the memory and file types don't exactly match HDF5 will do the type conversion and everything should still work.

jchelly commented 5 years ago

It might be best to hold off on merging this for now - the segfault no longer occurs but I'm having problems getting it to recognise a swift snapshot.