[ncl-talk] Infinite loop in ContourPlotInitialize

Mary Haley haley at ucar.edu
Thu May 31 15:28:06 MDT 2018


Hi Matthew,

Thanks for taking time to track down the location of the problem and
reporting it. I've created a ticket for this, NCL-2755.

We are indeed aware that NCL doesn't handle NaN and Inf values well. We
have an FAQ on this that may not be a very satisfactory answer, in that it
wouldn't haven't helped you debug the problem:

http://www.ncl.ucar.edu/FAQ/#data_hand_004

The issue goes beyond just trying to get NCL to contour the data properly.
If you have Infs/NaNs in your data, it's not going to work well for
computational routines either.

I'm curious whether the solution in the FAQ would help with your -Inf/Inf
case.

--Mary



On Wed, May 30, 2018 at 10:19 AM, Matthew Scutter <yellowplantain at gmail.com>
wrote:

> Hi ncl-talk,
> I think I have found an interesting bug in ContourPlotInitialize.
> It presents as an infinite loop in _NhlCmpFAny2 because anorm from ni/src/lib/nio/cmpf.c:508
> is infinity, which the function doesn't seem to have any handling for. This
> happens if the data you are trying to plot has values of -infinity
> (probably +infinity too), even if you have specified a sensible scale.
> I realise this data might not be considered valid, but I don't think an
> infinite loop is the correct handling of that. This took considerable time
> to debug and track down.
>
> I suggest special casing infinity in _NhlCmpFAny2.
>
> Disassembly notes attached:
>
> 0x0000000000b06a73 in _NhlCmpFAny2 ()
>
> (gdb) bt
>
> #0  0x0000000000b06a73 in _NhlCmpFAny2 ()
>
> #1  0x0000000000a4c6ef in SetupLevelsAutomatic ()
>
> #2  0x0000000000a4aaa8 in SetupLevels ()
>
> #3  0x0000000000a468a2 in ManageDynamicArrays ()
>
> #4  0x0000000000a6066e in ContourPlotInitialize ()
>
> #5  0x00000000009c451f in NhlCreate ()
>
> #6  0x00000000005fbfa2 in _NclCreateHLUObjOp ()
>
> #7  0x00000000005ee830 in CallCREATE_OBJ_OP ()
>
> #8  0x00000000005e4f3a in _NclExecute ()
>
> #9  0x00000000005fbb62 in _NclFuncCallOp ()
>
> #10 0x00000000005e5403 in _NclExecute ()
>
> #11 0x00000000005fbb62 in _NclFuncCallOp ()
>
> #12 0x00000000005e5403 in _NclExecute ()
>
> #13 0x00000000005fbb62 in _NclFuncCallOp ()
>
> #14 0x00000000005e5403 in _NclExecute ()
>
> #15 0x00000000005fbb62 in _NclFuncCallOp ()
>
> #16 0x00000000005e5403 in _NclExecute ()
>
> #17 0x00000000005fbaa2 in _NclProcCallOp ()
>
> #18 0x00000000005e530e in _NclExecute ()
>
> #19 0x000000000046d259 in yyparse ()
>
> #20 0x0000000000462dcf in NclDriver ()
>
> #21 0x000014e1ec9aa1c1 in __libc_start_main (main=0x45d3d0 <main>, argc=2,
> argv=0x7ffcae928808, init=<optimized out>, fini=<optimized out>,
> rtld_fini=<optimized out>, stack_end=0x7ffcae9287f8)
>
>     at ../csu/libc-start.c:308
>
> #22 0x000000000045d2f9 in _start ()
>
>
> (gdb) disassemble
>
> <snip>
>
>    0x0000000000b06a61 <+709>: mulsd  %xmm2,%xmm6
>
>    0x0000000000b06a65 <+713>: movaps %xmm5,%xmm1
>
>    0x0000000000b06a68 <+716>: mulsd  %xmm6,%xmm1
>
>    0x0000000000b06a6c <+720>: inc    %r14d
>
>    0x0000000000b06a6f <+723>: comisd %xmm7,%xmm1
>
> => 0x0000000000b06a73 <+727>: jae    0xb06a61 <_NhlCmpFAny2+709>
>
> </snip>
>
>
> register status:
>
> (gdb) print $xmm2
>
> $3 = {v4_float = {-1.58818684e-23, 1.44999993, 0, 0}, v2_double =
> {0.10000000000000001, 0}, v16_int8 = {-102, -103, -103, -103, -103, -103,
> -71, 63, 0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 = {-26214,
>
>     -26215, -26215, 16313, 0, 0, 0, 0}, v4_int32 = {-1717986918,
> 1069128089, 0, 0}, v2_int64 = {4591870180066957722, 0}, uint128 =
> 4591870180066957722}
>
> (gdb) print $xmm6
>
> $4 = {v4_float = {0, -nan(0x700000), 0, 0}, v2_double = {-inf, 0},
> v16_int8 = {0, 0, 0, 0, 0, 0, -16, -1, 0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 =
> {0, 0, 0, -16, 0, 0, 0, 0}, v4_int32 = {0, -1048576, 0,
>
>     0}, v2_int64 = {-4503599627370496, 0}, uint128 = 18442240474082181120}
>
> (gdb) print $xmm5
>
> $5 = {v4_float = {0, -1.875, 0, 0}, v2_double = {-1, 0}, v16_int8 = {0, 0,
> 0, 0, 0, 0, -16, -65, 0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 = {0, 0, 0, -16400,
> 0, 0, 0, 0}, v4_int32 = {0, -1074790400, 0, 0},
>
>   v2_int64 = {-4616189618054758400, 0}, uint128 = 13830554455654793216}
>
> (gdb) print $xmm1
>
> $6 = {v4_float = {0, nan(0x700000), 0, 0}, v2_double = {inf, 0}, v16_int8
> = {0, 0, 0, 0, 0, 0, -16, 127, 0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 = {0, 0,
> 0, 32752, 0, 0, 0, 0}, v4_int32 = {0, 2146435072,
>
>     0, 0}, v2_int64 = {9218868437227405312, 0}, uint128 =
> 9218868437227405312}
>
> (gdb) print $r14d
>
> $7 = -2142237121
>
> (gdb) print $xmm7
>
> $8 = {v4_float = {0, 1.875, 0, 0}, v2_double = {1, 0}, v16_int8 = {0, 0,
> 0, 0, 0, 0, -16, 63, 0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 = {0, 0, 0, 16368,
> 0, 0, 0, 0}, v4_int32 = {0, 1072693248, 0, 0},
>
>   v2_int64 = {4607182418800017408, 0}, uint128 = 4607182418800017408}
>
> (gdb)
>
>
>
> ni/src/lib/nio/cmpf.c:508:
>
>
>     while (anorm * asign >= 1.0) {
>
>     icount++;
>
>     aexp10++;
>
>     anorm *= .1;
>
>     }
>
>
> dubiously annotated disassembly:
>
>
>    0x0000000000b06a61 <+709>: mulsd  %xmm2,%xmm6 ; anorm *= 0.1
>
>    0x0000000000b06a65 <+713>: movaps %xmm5,%xmm1 ; asign = -1
>
>    0x0000000000b06a68 <+716>: mulsd  %xmm6,%xmm1 ; x = anorm * asign
>
>    0x0000000000b06a6c <+720>: inc    %r14d   ; icount++
>
>
>    0x0000000000b06a6f <+723>: comisd %xmm7,%xmm1 ; if (x >= 1.0) {goto
> 0xb06a61;}
>
> => 0x0000000000b06a73 <+727>: jae    0xb06a61 <_NhlCmpFAny2+709>
>
>
> If anorm/xmm2 is -infinity, the loop never exits.
>
> Best Regards,
> Matthew
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180531/fa987089/attachment.html>


More information about the ncl-talk mailing list