hyperion-rt / hyperion

Hyperion Radiative Transfer Code
http://www.hyperion-rt.org
BSD 2-Clause "Simplified" License
52 stars 26 forks source link

Segmentation fault with HDF5 1.8.5 and earlier #10

Closed astrofrog closed 11 years ago

astrofrog commented 12 years ago

The HDF5 table-writing (called by hdf5_copy_group at the start of Hyperion) causes a segmentation fault when field names have different lengths. The following script reproduces the issue:

program test

  use hdf5
  use h5tb

  implicit none
  integer :: hdferr = 0
  integer(hid_t) :: handle
  integer(size_t) :: type_size
  integer(hsize_t) :: start, nrecords
  integer(size_t) :: offsets(2)
  character(len=255) :: path
  character(len=10) :: fields(5)

  path = 'Angles'
  fields(1) = 'theta'
  fields(2) = 'phi'

  call h5open_f(hdferr)
  call h5fcreate_f('test.hdf5', h5f_acc_trunc_f, handle, hdferr)

  type_size = 16
  offsets = [0, 8]

  call h5tbmake_table_f('table_title', handle, path, 2, 1, type_size, &
       & fields, offsets, [h5t_ieee_f64le, h5t_ieee_f64le], 1, 0, hdferr)

  start = 0
  nrecords = 1
  type_size = 8

  call h5tbwrite_field_name_f(handle, path, trim(fields(1)), start, nrecords, type_size, [1._8], hdferr)
  call h5tbwrite_field_name_f(handle, path, trim(fields(2)), start, nrecords, type_size, [1._8], hdferr)

end program test

The error is just a normal segmentation fault:

forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
air                00000001001EB932  Unknown               Unknown  Unknown
air                00000001001732E2  Unknown               Unknown  Unknown
air                0000000100175887  Unknown               Unknown  Unknown
air                000000010015DCEB  Unknown               Unknown  Unknown
air                000000010005A956  Unknown               Unknown  Unknown
air                000000010005B8AC  Unknown               Unknown  Unknown
air                000000010000CF25  Unknown               Unknown  Unknown
air                0000000100001A30  Unknown               Unknown  Unknown
air                0000000100002959  Unknown               Unknown  Unknown
air                00000001000013CA  Unknown               Unknown  Unknown
air                000000010000110C  Unknown               Unknown  Unknown
air                00000001000010C4  Unknown               Unknown  Unknown

The release notes for HDF5 indicate that this was a known bug, and is fixed in 1.8.6+:

h5tbmake_table_f: Fixed error in passing an array of characters with different length field names.

Waiting for a reply from HDF5 developers for a workaround (if possible).

astrofrog commented 11 years ago

HDF5 1.8.5 is now over three years old - not worth fixing.