[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #IRQ-325570]: nc_test/large_file.c problem and patch



Hi Gus,

Sorry for taking so long to respond to your comment and bug fix.
> The large file test program in nc_test/large_file.c seems to have a bug.
> The "int n" number used to provide data via cast to signed char
> overflows the integer range.
> 
> The value of n grows up to the product of:
> 
> NUMRECS+1 = 1+1
> I_LEN+1 = 4104+1
> J_LEN+1 = 1023+1
> K_LEN+1 = 1023+1
> 
> which is a number beyond the maximum "int" value of 2147438648.
> 
> I am not a C programmer, but I would guess also
> that casting integer values above the range of signed
> char [-128,127], or unsigned values in the range [0,255]
> is not guaranteed to be supported by all compilers.
> 
> I am building NetCDF4 on Linux x86_64.
> Somehow the Gnu gfortran and Intel icc compile
> the original code and run without problems.
> However, PGI pgcc breaks down there.
> 
> Here is a patch that I applied to that file which removes the overflow,
> and reduces the integer "n" to range [0,255] to use the cast
> (signed char) n.
> With this patch the test program works in pgcc.
> 
> #####################################
> 
> 129c129,131
> <                    var1[j][k] = n++;
> ---
> >                  var1[j][k] = (signed char) n;
> >                  n++;
> >                  n %= 255;
> 171a174
> >                    n %= 255;

Thanks, I've incorporated a fix into our upcoming snapshot release, and
it should appear in the 4.1.2 release.

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: IRQ-325570
Department: Support netCDF
Priority: Critical
Status: Closed


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.