HDFGroup / vol-rest

HDF5 REST VOL Connector
Other
5 stars 8 forks source link

Invalid memory read when using type conversion with selection #125

Closed mattjala closed 4 months ago

mattjala commented 4 months ago

Program to replicate the error:

int main() {
  hid_t file_id = H5I_INVALID_HID;
  hid_t dset_id = H5I_INVALID_HID;
  const hsize_t dims[] = {COUNT};

 // Select indices 2,3, 5, and 6
  hssize_t start[1] = {2};
  hssize_t stride[1] = {3};
  hssize_t block[1] = {2};
  hssize_t count[1] = {2};

  int int_buf[COUNT];
  int int_buf2[COUNT];
  memset(int_buf2, 0, sizeof(int) * COUNT);

  hid_t int_id = H5Tcopy(H5T_NATIVE_INT);
  hid_t float_id = H5Tcopy(H5T_NATIVE_FLOAT);
  file_id = H5Fcreate("/home/test_user1/tfile.c", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
  hid_t space_id = H5Screate_simple(1, dims, NULL);
  dset_id = H5Dcreate2(file_id, "dset", float_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

  for (size_t i = 0; i < COUNT; i++)
    int_buf[i] = i;

  H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, stride, count, block);

  H5Dwrite(dset_id, int_id, H5S_ALL, space_id, H5P_DEFAULT, int_buf);
}
mattjala commented 4 months ago

Resolved in #124