Menu

#35 Memory allocation issues

1.5.7
closed-fixed
tbeu
None
5
2016-06-22
2016-06-16
flelchuk
No

Hi,

While loading a large complex (double) variable from a MAT file,
I received the following warning from HDF5:

HDF5-DIAG: Error detected in HDF5 (1.8.17) thread 0:
000: C:\xxx\hdf5-1.8.17\src\H5Dio.c line 173 in H5Dread(): can't read data
major: Dataset
minor: Read failed
001: C:\xxx\hdf5-1.8.17\src\H5Dio.c line 446 in H5Dread(): no output buffer
major: Invalid arguments to routine
minor: Bad value
HDF5-DIAG: Error detected in HDF5 (1.8.17) thread 0:
000: C:\xxx\hdf5-1.8.17\src\H5Dio.c line 173 in H5Dread(): can't read data
major: Dataset
minor: Read failed
001: C:\xxx\hdf5-1.8.17\src\H5Dio.c line 446 in H5Dread(): no output buffer
major: Invalid arguments to routine
minor: Bad value

I tracked down the problem in mat73.c:

complex_data->Re = malloc(matvar->nbytes);
complex_data->Im = malloc(matvar->nbytes);
/* ... */
H5Dread(/* ... */, complex_data->Re);

There are multiple occurences of such kind. Please add checks to make sure both malloc calls succeed.
Thanks for this lovely library :-)

Best regards,

Felix Lelchuk

Discussion

  • tbeu

    tbeu - 2016-06-16
    • status: open --> accepted
    • assigned_to: tbeu
    • Group: master --> 1.5.7
     
  • tbeu

    tbeu - 2016-06-21

    Can you share a number how many bytes you tried to allocate?

     
  • tbeu

    tbeu - 2016-06-21

    Should be fixed by f067ed1.

     
  • flelchuk

    flelchuk - 2016-06-22

    Great, thanks. Iirc, I was dealing with a 4x128x256x512 4-dimensional array of complex double.
    I guess the second malloc could not succeed on 32-bit Windows anyway.

     
  • tbeu

    tbeu - 2016-06-22
    • status: accepted --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB