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

970529: netcdf 3.3 with gcc



Kate,

>Date: Thu, 29 May 1997 11:47:31 -0400 (EDT) 
>From: Kate Hedstrom <address@hidden>
>Organization: Rutgers University
>To: address@hidden
>Subject: Re: 970528: netcdf 3.3 with gcc 
>Keywords: 199705171514.JAA09636

In the above message, you wrote:

> > > *** Testing nc_get_var_uchar ... 
> > >         FAILURE at line 793 of test_get.c: value read not that expected
> > 
> > Would you please do me the following favor:
> > 
> >     1.  Go into the nc_test/ subdirectory.
> > 
> >     2.  Execute the command "make test.nc".
> > 
> >     3.  Execute the debugger on the file nc_test.
> > 
> >     4.  Set a breakpoint in the function "error".
> > 
> >     5.  Run the executable in the debugger.
> 
> It gets a floating point exception before getting here.

Ah!  gdb(1) is apparently intercepting the SIGFPE signal.  nc_test(1) is
designed to intercept SIGFPE and carry-on.  You need to tell gdb(1) to
ignore SIGFPE so that it'll stop at the breakpoint in function "error".

> 
> (gdb) where
> #0  0x4a299 in ncx_get_float_uchar (xp=0x6a7f0, ip=0xefbfd7bc "") at
> ncx.c:1129
> #1  0x4c1af in ncx_getn_float_uchar (xpp=0xefbfd520, nelems=1, 
>     tp=0xefbfd7bc "") at ncx.c:3214
> #2  0x50f8e in getNCvx_float_uchar (ncp=0x69000, varp=0x69400,
> start=0x6f300, 
>     nelems=1, value=0xefbfd7bc "") at putget.c:3337
> #3  0x51cb2 in getNCv_uchar (ncp=0x69000, varp=0x69400, start=0x6f300, 
>     nelems=1, value=0xefbfd7bc "") at putget.c:3880
> #4  0x55b9e in nc_get_var_uchar (ncid=6, varid=10, value=0xefbfd7bc "")
>     at putget.c:7285
> #5  0x9a4f in test_nc_get_var_uchar () at test_get.c:776
> #6  0x3c99 in main (argc=1, argv=0xefbfd848) at nc_test.c:168
> 
>  
> >     6.  When execution stops in function "error", go up to function
> >     "test_nc_get_var_uchar".
> > 
> >     7.  Print out the values of the following variables:
> > 
> >         i,var_name[i],var_type[i],j,expect[j],value[j]
> 
> Breakpoint 3, test_nc_get_var_uchar () at test_get.c:776
> 776             err = nc_get_var_uchar(ncid, i, value);
> (gdb) p i
> $14 = 10
> (gdb) p var_name[i]
> $15 = "fr\000\000"
> (gdb) p *var_name[i]
> $16 = 102 'f'
> (gdb) p var_type[i]
> $17 = NC_FLOAT
> (gdb) p j
> $18 = 2
> (gdb) p expect[j]
> $19 = 639960
> (gdb) p value[j]
> $20 = 72 'H'
> 
> 
> Down where the trouble is:
> 
> 1124    int
> 1125    ncx_get_float_uchar(const void *xp, uchar *ip)
> 1126    {
> 1127            float xx;
> 1128            get_ix_float(xp, &xx);
> 1129            *ip = (uchar) xx;
> 1130            if(xx > UCHAR_MAX || xx < 0)
> 1131                    return NC_ERANGE;
> 1132            return ENOERR;
> (gdb) n
> 1129            *ip = (uchar) xx;
> (gdb) p xx
> $28 = -3.40282347e+38
> (gdb) n
> 
> Program received signal SIGFPE, Arithmetic exception.
> 0x4a299 in ncx_get_float_uchar (xp=0x6a7f0, ip=0xefbfd7bc "") at
> ncx.c:1129
> 1129            *ip = (uchar) xx;
> 
> 
> Why don't you do the cast after the check for UCHAR_MAX?

Because we need to be backward compatible with netCDF-2, which just gave
you the bits with no indication of an error.  So we still need to give
you the bits (in case you really, really want them).  Since nc_test(1)
handles SIGFPE, this shouldn't be a problem.

Your netCDF build is probably OK.  The problem you're encountering has
more to due with the testing procedures than with the netCDF-3 library.

In order to verify this, however, would you please tell gdb(1) to ignore
SIGFPE, stop at the "error" breakpoint, and print those variables I
mentioned.

--------
Steve Emmerson   <address@hidden>