Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cephes_smirnov nan-to-int conversion bug (Trac #1638) #2163

Closed
scipy-gitbot opened this issue Apr 25, 2013 · 3 comments
Closed

cephes_smirnov nan-to-int conversion bug (Trac #1638) #2163

scipy-gitbot opened this issue Apr 25, 2013 · 3 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac scipy.special
Milestone

Comments

@scipy-gitbot
Copy link

Original ticket http://projects.scipy.org/scipy/ticket/1638 on 2012-03-30 by @pv, assigned to @pv.

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=653948
http://permalink.gmane.org/gmane.comp.python.scientific.devel/16262


The cephes_smirnov function in kolmogorov.c can go into a very long loop, due to the following line of code

      double e;
      ...
      nn = (int) (floor ((double) n * (1.0 - e)));

If e happens to be nan, the value of nn is unspecified. It is used as a loop upper bound, so it will effectively hang the process.

The cast miraculously seems to work OK (gives zero?) on x86, but produces large numbers on MIPS.

There are probably also other instances of this bug in the code. All float-to-integer casts where the operand may be NAN probably should be guarded by n = (int)x; if (x - n != 0) { mtherr(...); return NPY_NAN; } or something like that (this would also protect against integer overflow).

@scipy-gitbot
Copy link
Author

@pv wrote on 2012-03-31

PR http://github.com/scipy/scipy/pull/187

@scipy-gitbot
Copy link
Author

@pv wrote on 2012-05-11

Fixed in 3418836f832

@scipy-gitbot
Copy link
Author

Milestone changed to 0.11.0 by @pv on 2012-05-11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac scipy.special
Projects
None yet
Development

No branches or pull requests

1 participant