diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2012-05-16 21:16:20 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2012-05-16 21:16:20 (GMT) |
commit | 27535adaa934d4e2d0384428a72645c102dd88fa (patch) | |
tree | 435b6f5a7ff5816a0172cc582ed30aeb071366e5 /tools | |
parent | 6e1a85e78107d24261cc33f897619291e2456011 (diff) | |
download | hdf5-27535adaa934d4e2d0384428a72645c102dd88fa.zip hdf5-27535adaa934d4e2d0384428a72645c102dd88fa.tar.gz hdf5-27535adaa934d4e2d0384428a72645c102dd88fa.tar.bz2 |
[svn-r22373] 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), koala (linux64-LE), ostrich (linuxppc64-BE)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5repack/h5repacktst.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index bc94eed..4f1707b 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -3547,7 +3547,6 @@ out: * *------------------------------------------------------------------------- */ - static int write_dset_in(hid_t loc_id, const char* dset_name, /* for saving reference to dataset*/ @@ -3811,17 +3810,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) @@ -3830,7 +3835,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); |