H5Dread and hyperslab bug

Hello

I'm experiencing a strange bug here.

I have a dataset and an associated dataspace, wich select a part of the dataset.

If i select all my memory dataspace using H5Sselect_hyperslab and use H5Dread, i get a Segmentation fault (core dumped).
If i allocate a bigger place than necessary for the reading buffer, the seg fault disappear and all works like there is no problem.

This problem doesn't appear with H5Sselect_all.

I will provide a sample code tomorow.

In the meantime, if anybody had the same problem, i will be glad to hear about it.

Thanks

Mathieu
.

Hi Mathieu,

We don't see your problem.
We're reading hyperslab data into contiguous memory as shown below. It
selects the right amount of memory.
It works fine on hdf5-1.8.3 till at least 1.8.7.
This code snippet is test code. Some variables are defined globally,
thus not allocated or passed here.

Cheers,
Ger

void get (int stx, int sty, int stz, int nx, int ny, int nz, void* buf)

{
  // Define the data set selection.
  hsize_t offset[3], count[3], stride[3];
  offset[0] = stz; count[0] = nz; stride[0] = 1;
  offset[1] = sty; count[1] = ny; stride[1] = 1;
  offset[2] = stx; count[2] = nx; stride[2] = 1;
  check (H5Sselect_hyperslab (dsId, H5S_SELECT_SET, offset,
                              stride, count, NULL),
         "invalid data set array selection");
  // Define a data space for the memory buffer.
  hid_t dsmemid = H5Screate_simple (3, count, NULL);
  check (dsmemid, "Failed to create memory data space");
  // Define memory selection.
  offset[0]=0; offset[1]=0; offset[2] = 0;
  check (H5Sselect_hyperslab (dsmemid, H5S_SELECT_SET, offset,
                              NULL, count, NULL),
         "Failed to set slab of memory buffer");
  // Read the data.
  check (H5Dread (setId, typeIdMem, dsmemid, dsId,
                  H5P_DEFAULT, buf),
         "Failed to read slab from data set array");
  H5Sclose (dsmemid);
}

Mathieu westphal <mathieu.westphal@obs.ujf-grenoble.fr> 5/29/2012

5:04 PM >>>
Hello

I'm experiencing a strange bug here.

I have a dataset and an associated dataspace, wich select a part of
the
dataset.

If i select all my memory dataspace using H5Sselect_hyperslab and use
H5Dread, i get a Segmentation fault (core dumped).
If i allocate a bigger place than necessary for the reading buffer,
the
seg fault disappear and all works like there is no problem.

This problem doesn't appear with H5Sselect_all.

I will provide a sample code tomorow.

In the meantime, if anybody had the same problem, i will be glad to
hear
about it.

Thanks

Mathieu
.

···

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Hello
it was an internal error in my code, sorry for bothering you.

Mathieu

···

On 05/30/2012 11:34 AM, Ger van Diepen wrote:

Hi Mathieu,

We don't see your problem.

We're reading hyperslab data into contiguous memory as shown below. It selects the right amount of memory.

It works fine on hdf5-1.8.3 till at least 1.8.7.

This code snippet is test code. Some variables are defined globally, thus not allocated or passed here.

Cheers,

Ger

void get (int stx, int sty, int stz, int nx, int ny, int nz, void* buf)

{

  // Define the data set selection.

  hsize_t offset[3], count[3], stride[3];

  offset[0] = stz; count[0] = nz; stride[0] = 1;

  offset[1] = sty; count[1] = ny; stride[1] = 1;

  offset[2] = stx; count[2] = nx; stride[2] = 1;

  check (H5Sselect_hyperslab (dsId, H5S_SELECT_SET, offset,

                              stride, count, NULL),

         "invalid data set array selection");

  // Define a data space for the memory buffer.

  hid_t dsmemid = H5Screate_simple (3, count, NULL);

  check (dsmemid, "Failed to create memory data space");

  // Define memory selection.

  offset[0]=0; offset[1]=0; offset[2] = 0;

  check (H5Sselect_hyperslab (dsmemid, H5S_SELECT_SET, offset,

                              NULL, count, NULL),

         "Failed to set slab of memory buffer");

  // Read the data.

  check (H5Dread (setId, typeIdMem, dsmemid, dsId,

                  H5P_DEFAULT, buf),

         "Failed to read slab from data set array");

  H5Sclose (dsmemid);

}

>>> Mathieu westphal <mathieu.westphal@obs.ujf-grenoble.fr> 5/29/2012 5:04 PM >>>
Hello

I'm experiencing a strange bug here.

I have a dataset and an associated dataspace, wich select a part of the
dataset.

If i select all my memory dataspace using H5Sselect_hyperslab and use
H5Dread, i get a Segmentation fault (core dumped).
If i allocate a bigger place than necessary for the reading buffer, the
seg fault disappear and all works like there is no problem.

This problem doesn't appear with H5Sselect_all.

I will provide a sample code tomorow.

In the meantime, if anybody had the same problem, i will be glad to hear
about it.

Thanks

Mathieu
.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org