From 6dc6cf65bae5ece221e9bd8fc0801a0a98382211 Mon Sep 17 00:00:00 2001 From: Dennis Heimbigner Date: Tue, 2 May 2017 21:22:54 -0600 Subject: [PATCH] re: issue https://github.com/Unidata/netcdf-c/issues/401 It turns out that the chunksize used in the ncio-related code must be a multiple of eight in size. Both memio.c and mmapio.c were potentially violating this constraint. See also pr https://github.com/Unidata/netcdf-c/pull/400 --- libsrc/memio.c | 4 ++++ libsrc/mmapio.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libsrc/memio.c b/libsrc/memio.c index 8cda908c92..600f15021f 100644 --- a/libsrc/memio.c +++ b/libsrc/memio.c @@ -385,6 +385,10 @@ fprintf(stderr,"memio_open: initial memory: %lu/%lu\n",(unsigned long)memio->mem /* Use half the filesize as the blocksize ; why? */ sizehint = filesize/2; + /* sizehint must be multiple of 8 */ + sizehint = (sizehint / 8) * 8; + if(sizehint < 8) sizehint = 8; + fd = nc__pseudofd(); *((int* )&nciop->fd) = fd; diff --git a/libsrc/mmapio.c b/libsrc/mmapio.c index 5681fc7e2b..17a35f2037 100644 --- a/libsrc/mmapio.c +++ b/libsrc/mmapio.c @@ -373,6 +373,10 @@ fprintf(stderr,"mmapio_open: initial memory: %lu/%lu\n",(unsigned long)mmapio->m /* Use half the filesize as the blocksize */ sizehint = filesize/2; + /* sizehint must be multiple of 8 */ + sizehint = (sizehint / 8) * 8; + if(sizehint < 8) sizehint = 8; + fd = nc__pseudofd(); *((int* )&nciop->fd) = fd;