Opened 6 years ago

Closed 4 years ago

#12961 closed Bugs (invalid)

boost::math::cyl_bessel_i crashes program.

Reported by: theivorytower@… Owned by: John Maddock
Milestone: To Be Determined Component: math
Version: Boost 1.63.0 Severity: Showstopper
Keywords: Cc:

Description

When trying to compute boost::math::cyl_bessel_i(0.2, 0.014), the program crashes with numerical overflow error. The expected value should be 0.404. Using some other values as argument can produce crash-free program.

The crash happens with gcc 6.3.1 and clang 3.9.1. Attached is a sample code that crashes during run-time.

Attachments (1)

bessel.cpp (152 bytes ) - added by theivorytower@… 6 years ago.
Sample code that crashes.

Download all attachments as: .zip

Change History (5)

by theivorytower@…, 6 years ago

Attachment: bessel.cpp added

Sample code that crashes.

comment:1 by John Maddock, 6 years ago

I'm unable to reproduce this, either on Windows (MSVC) or on Ubuntu Linux with GCC.

What's the OS?

You can help me a little by stepping through your sample program in the debugger - you should get to:

bessel.hpp:221 return bessel_i_small_z_series(v, x, pol);

And then stepping into that should lead to the rather trivial evaluation in:

bessel_ik.hpp:78 return prefix * result;

With

prefix = 0.40373565439688797 and result = 1.0000408337880704

comment:2 by theivorytower@…, 6 years ago

Thanks for the reply. I'm using Arch Linux.

When I get to bessel_ik.hpp:78 return prefix * result, the variables are prefix = inf and result = 1.000040833788070502945698192487356.

When I step in a little further, I find the reason prefix was evaluated to be infinite was because pow(x / 2, v) was evaluated to be infinite! So this is must be a bug with libstdc++. Sorry this is not a bug with boost. FYI with my libstdc++ I find std::pow(x, y) ALWAYS returns infinite whenever y is long double. I will dig further into libstdc++...

comment:3 by John Maddock, 6 years ago

As a workaround you could define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS which would disable all use of the long double std lib functions internally.

comment:4 by John Maddock, 4 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.