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

[netCDF #RJV-358050]: Expect NF_ERANGE but got a coredump when using NAG Fortran compiler

Hi Wei-keng,

That's a good question; it would make sense for the check to come first and for 
the range error to to be reported.  As to whether or not the attribute should 
be created or not nevertheless, I can see where the design decision may have 
gone either way.  I can discuss this internally and try to find out if this is 
a mistake or a design decision.  

Thank you for the report; I'll see what I can sort out.  As an aside, I'm 
currently working on the final touches of merging your cdf-5 work into the 
master branch for the full 4.4.0 release; the bulk of the work was done by 
Dennis Heimbigner, but there are a couple small issues to take care of before 
the merge is completed.

Thanks again, have a great day,


> Hi,
> When calling nf_put_att_double to create an attribute of type NF_INT using a 
> value > X_INT_MAX on purpose, I expect to get NF_ERANGE error code, but got a 
> coredump and an error message below:
> Runtime Error: *** Arithmetic exception: Floating invalid operation - aborting
> Abort (core dumped)
> The test program is attached.
> I am using the followings:
> netcdf-fortran-4.4.2
> netcdf-c-4.4.0-rc3
> gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
> NAG Fortran Compiler Release 6.0
> The coredump trace points to line 945 of libsrc/ncx.m4 which assigns the 
> overflowed value before checking the overflow at line 947.
> 943 ncx_put_int_double(void *xp, const double *ip)
> 944 {
> 945         ix_int xx = (ix_int)(*ip);
> 946         put_ix_int(xp, &xx);
> 947         if(*ip > X_INT_MAX || *ip < X_INT_MIN)
> 948                 return NC_ERANGE;
> 949         return ENOERR;
> 950 }
> Two questions.
> 1. Should the checking be done before the assignment? This affects other 
> subroutines as well in ncx.m4.
> 2. When nf_put_att_double failed with NF_ERANGE, should the attribute still 
> be created? I can see the attribute created from command ncdump.
> Here is the core trace.
> (gdb) where
> #0  0x00007fcae29b10d5 in __GI_raise (sig=<optimized out>) at 
> ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> #1  0x00007fcae29b483b in __GI_abort () at abort.c:91
> #2  0x00007fcae2dda3e0 in __NAGf90_signal_handler () from 
> /soft/com/packages/nag-6.0/lib/libf60rts.so.1
> #3  <signal handler called>
> #4  0x00007fcadf68f86c in ncx_put_int_double (xp=0x9cb0a8, ip=0x60b1a8) at 
> ncx.m4:945
> #5  0x00007fcadf693862 in ncx_putn_int_double (xpp=0x7fffd1421568, nelems=1, 
> tp=0x60b1a8) at ncx.m4:2871
> #6  0x00007fcadf688fcf in ncx_pad_putn_Idouble (xpp=0x7fffd1421568, nelems=1, 
> tp=0x60b1a8, type=4) at attr.m4:690
> #7  0x00007fcadf6893da in dispatchput (xpp=0x7fffd1421568, nelems=1, 
> tp=0x60b1a8, atype=4, memtype=6) at attr.m4:719
> #8  0x00007fcadf689707 in NC3_put_att (ncid=65536, varid=-1, 
> name=0x7fcae3789030 "attr", type=4, nelems=1, value=0x60b1a8, memtype=6) at 
> attr.m4:830
> #9  0x00007fcadf669c71 in nc_put_att_double (ncid=65536, varid=-1, 
> name=0x7fcae3789030 "attr", xtype=4, len=1, value=0x60b1a8) at dattput.c:309
> #10 0x00007fcae33c6f11 in nf_put_att_double_ (ncid_=0x60b1a0, 
> varid_=0x7fffd1421734, name_=0x40a1f4 "attr", xtype_=0x7fffd1421738, 
> nlen_=0x7fffd142173c,
> dvals_=0x60b1a8, name_Len=4) at nf_attio.F90:307
> #11 0x0000000000409ef9 in main (argc=1, argv=0x7fffd1421828) at attrf.f:13
> Wei-keng

Ticket Details
Ticket ID: RJV-358050
Department: Support netCDF
Priority: Normal
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.