summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-06-09 21:11:41 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-06-09 21:11:41 (GMT)
commitab58cdcecd186a3993913fdfbf7c598c24248213 (patch)
tree9d59307aa15610fe8aa18c26be1d67dab87a3c75 /src
parent5493f48ccb5c70fe765f95f0bccdb4c07338bc76 (diff)
downloadhdf5-ab58cdcecd186a3993913fdfbf7c598c24248213.zip
hdf5-ab58cdcecd186a3993913fdfbf7c598c24248213.tar.gz
hdf5-ab58cdcecd186a3993913fdfbf7c598c24248213.tar.bz2
[svn-r17021] Description:
Make error handling for detecting overlaps between 'normal' and 'temporary' space allocation more robust. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.7 (amazon) in debug mode Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src')
-rw-r--r--src/H5FDstdio.c2
-rw-r--r--src/H5MF.c8
-rw-r--r--src/H5MFaggr.c30
3 files changed, 33 insertions, 7 deletions
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index 0ae09a6..193c576 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -147,8 +147,10 @@ typedef struct H5FD_stdio_t {
#define REGION_OVERFLOW(A,Z) (ADDR_OVERFLOW(A) || SIZE_OVERFLOW(Z) || \
HADDR_UNDEF==(A)+(Z) || (file_offset_t)((A)+(Z))<(file_offset_t)(A))
+#ifndef H5_HAVE_FSEEKO
/* Define big file as 2GB */
#define BIG_FILE 0x80000000UL
+#endif
/* Prototypes */
static H5FD_t *H5FD_stdio_open(const char *name, unsigned flags,
diff --git a/src/H5MF.c b/src/H5MF.c
index 8beac3b..a3769d1 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -382,9 +382,8 @@ HDfprintf(stderr, "%s: Check 2.0\n", FUNC);
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate raw data")
} /* end else */
- /* Check for overlapping into file's temporary allocation space */
- if(H5F_addr_gt((ret_value + size), f->shared->tmp_addr))
- HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request overlaps into 'temporary' file space")
+ /* Sanity check for overlapping into file's temporary allocation space */
+ HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr));
done:
#ifdef H5MF_ALLOC_DEBUG
@@ -428,6 +427,9 @@ H5MF_alloc_tmp(H5F_t *f, hsize_t size)
haddr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5MF_alloc_tmp, HADDR_UNDEF)
+#ifdef H5MF_ALLOC_DEBUG
+HDfprintf(stderr, "%s: size = %Hu\n", FUNC, size);
+#endif /* H5MF_ALLOC_DEBUG */
/* check args */
HDassert(f);
diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c
index f383e23..0f8a374 100644
--- a/src/H5MFaggr.c
+++ b/src/H5MFaggr.c
@@ -119,6 +119,9 @@ HDfprintf(stderr, "%s: type = %u, size = %Hu\n", FUNC, (unsigned)type, size);
HDassert(type >= H5FD_MEM_DEFAULT && type < H5FD_MEM_NTYPES);
HDassert(size > 0);
+ if(HADDR_UNDEF == (eoa = H5F_get_eoa(f, type)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, HADDR_UNDEF, "Unable to get eoa")
+
/*
* If the aggregation feature is enabled for this file, allocate "generic"
* space and sub-allocate out of that, if possible. Otherwise just allocate
@@ -138,9 +141,6 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz
frag_size = alignment - mis_align;
}
- if (HADDR_UNDEF == (eoa = H5F_get_eoa(f, type)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "Unable to get eoa")
-
alloc_type = aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW;
other_alloc_type = other_aggr->feature_flag == H5FD_FEAT_AGGREGATE_METADATA ? H5FD_MEM_DEFAULT : H5FD_MEM_DRAW;
@@ -149,9 +149,12 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz
/* Check if the block asked for is too large for 'normal' aggregator block */
if(size >= aggr->alloc_size) {
-
hsize_t ext_size = size + frag_size;
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
if ((aggr->addr > 0) && (extended=H5FD_try_extend(f->shared->lf, alloc_type, aggr->addr + aggr->size, ext_size)) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space")
else if (extended) {
@@ -160,6 +163,10 @@ HDfprintf(stderr, "%s: aggr = {%a, %Hu, %Hu}\n", FUNC, aggr->addr, aggr->tot_siz
aggr->addr += ext_size;
aggr->tot_size += ext_size;
} else {
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((eoa + size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
if ((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) &&
((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) {
@@ -189,6 +196,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
if (frag_size > (ext_size - size))
ext_size += (frag_size - (ext_size - size));
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((aggr->addr + aggr->size + ext_size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
if ((aggr->addr > 0) && (extended = H5FD_try_extend(f->shared->lf, alloc_type, aggr->addr + aggr->size, ext_size)) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't extending space")
else if (extended) {
@@ -196,6 +207,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
aggr->size += (ext_size - frag_size);
aggr->tot_size += ext_size;
} else {
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((eoa + aggr->alloc_size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
if ((other_aggr->size > 0) && (H5F_addr_eq((other_aggr->addr + other_aggr->size), eoa)) &&
((other_aggr->tot_size - other_aggr->size) >= other_aggr->alloc_size)) {
@@ -250,6 +265,10 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
}
} /* end if */
else {
+ /* Check for overlapping into file's temporary allocation space */
+ if(H5F_addr_gt((eoa + size), f->shared->tmp_addr))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_BADRANGE, HADDR_UNDEF, "'normal' file space allocation request will overlap into 'temporary' file space")
+
/* Allocate data from the file */
if(HADDR_UNDEF == (ret_value = H5FD_alloc(f->shared->lf, dxpl_id, type, size, &eoa_frag_addr, &eoa_frag_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, HADDR_UNDEF, "can't allocate file space")
@@ -258,6 +277,9 @@ HDfprintf(stderr, "%s: Allocating block\n", FUNC);
HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free eoa fragment")
} /* end else */
+ /* Sanity check for overlapping into file's temporary allocation space */
+ HDassert(H5F_addr_le((ret_value + size), f->shared->tmp_addr));
+
done:
#ifdef H5MF_AGGR_DEBUG
HDfprintf(stderr, "%s: ret_value = %a\n", FUNC, ret_value);