summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2012-05-16 21:42:18 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2012-05-16 21:42:18 (GMT)
commitc11b378c891d0f1209ad5af499ecd94466868528 (patch)
treec08da4251d0539ac5d320eda9a9494d9e59c845e /tools
parent80e66f6d428e10ac234ae4967fef5d762ae97f6b (diff)
downloadhdf5-c11b378c891d0f1209ad5af499ecd94466868528.zip
hdf5-c11b378c891d0f1209ad5af499ecd94466868528.tar.gz
hdf5-c11b378c891d0f1209ad5af499ecd94466868528.tar.bz2
[svn-r22374] Purpose:
Fix h5repacktst (test file generating binary) to address HDFFV-8016 h5repacktst failed in AIX 32bit mode Description: Segmentation fault occurred when h5repacktst try to generate a dataset when system memory is limited to 256MB. Add error handling to display apporiate message to exit and adjust the test dataset according to the original size which didn't causing out of memory. Tested: test was done by limit memory in csh. jam (linux32-LE), ostrich (linuxppc64-BE)
Diffstat (limited to 'tools')
-rw-r--r--tools/h5repack/h5repacktst.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 20dbcd4..5cc1785 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -3521,7 +3521,6 @@ out:
*
*-------------------------------------------------------------------------
*/
-
static
int write_dset_in(hid_t loc_id,
const char* dset_name, /* for saving reference to dataset*/
@@ -3785,17 +3784,23 @@ int write_dset_in(hid_t loc_id,
{
+ hsize_t TEST_BUFSIZE = (128 * 1024 * 1024); /* 128MB */
double *dbuf; /* information to write */
size_t size;
hsize_t sdims[] = {1};
- hsize_t tdims[] = {H5TOOLS_MALLOCSIZE / sizeof(double) + 1};
+ hsize_t tdims[] = {TEST_BUFSIZE / sizeof(double) + 1};
unsigned u;
/* allocate and initialize array data to write */
- size = ( H5TOOLS_MALLOCSIZE / sizeof(double) + 1 ) * sizeof(double);
+ size = ( TEST_BUFSIZE / sizeof(double) + 1 ) * sizeof(double);
dbuf = (double*)malloc( size );
+ if (NULL == dbuf)
+ {
+ printf ("\nError: Cannot allocate memory for \"arrayd\" data buffer size %dMB.\n", (int) size / 1000000 );
+ goto out;
+ }
- for( u = 0; u < H5TOOLS_MALLOCSIZE / sizeof(double) + 1; u++)
+ for( u = 0; u < TEST_BUFSIZE / sizeof(double) + 1; u++)
dbuf[u] = u;
if (make_diffs)
@@ -3804,7 +3809,7 @@ int write_dset_in(hid_t loc_id,
dbuf[6] = 0;
}
- /* create a type larger than H5TOOLS_MALLOCSIZE */
+ /* create a type larger than TEST_BUFSIZE */
if ((tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims)) < 0)
goto out;
size = H5Tget_size(tid);