[SciPy-Dev] cephes_smirnov never returns on mips/sparc/...

Pauli Virtanen pav@iki...
Fri Mar 30 15:59:21 CDT 2012


Hi,

30.03.2012 22:37, Yaroslav Halchenko kirjoitti:
> ok -- here is the reason:
> 
> (gdb) print e
> $27 = nan(0x8000000000000)
> (gdb) print ((double) n * (1.0 - e)) 
> $26 = nan(0x100000001)
> (gdb) print (floor ((double) n * (1.0 - e)))
> $25 = 2146435073

Thanks a lot:

kolmogorov.c:41
	nn = (int) (floor ((double) n * (1.0 - e)));

This is just wrong -- if `e` happens to be NAN, the result of the
integer cast is unspecified (as per C99 standard).

Probably there should be a blanket input finiteness check in most of the
routines. I'd be willing to bet that this is not the only bug of this
type in there. Detecting these automatically would require some control
flow analysis, so I guess the only option is to go through each function
manually :/

	Pauli




More information about the SciPy-Dev mailing list