Opened 6 years ago

Closed 6 years ago

#12625 closed Bugs (fixed)

multiprecision acos() sometimes does not return

Reported by: steve@… Owned by: John Maddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.62.0 Severity: Problem
Keywords: Cc: steve@…, thibaut@…

Description

Thibaut Paumard reported the following bug to Debian as https://bugs.debian.org/844495

Some inputs cause multiprecision acos() to hang. The following example hangs on s390x:

#include <boost/multiprecision/cpp_dec_float.hpp>

int main(int argc, char** argv) {

  boost::multiprecision::cpp_dec_float_100 alpha100, a, b;
  alpha100=5.9839860068377014046259e-02;
  b=cos(alpha100);
  a=acos(b);

  return 0;
}

Known affected architectures include arm64 armel armhf mips64el mipsel ppc64el s390x powerpc ppc64. It's not clear to me whether the value of alpha100 needs to be adjusted to trigger the bug on different architectures.

Thibaut has proposed the attached patch. Would appreciate knowing the maintainer's thoughts about the patch.

Attachments (1)

no-fp-ilogb0 (1.4 KB ) - added by steve@… 6 years ago.
patch for bug

Download all attachments as: .zip

Change History (4)

by steve@…, 6 years ago

Attachment: no-fp-ilogb0 added

patch for bug

comment:1 by Thibaut Paumard <thibaut@…>, 6 years ago

Cc: thibaut@… added

comment:2 by Thibaut Paumard <thibaut@…>, 6 years ago

Hi,

Although I haven't yet been able to demonstrate that acos() can hang on amd64, I confirm that ilogb(zero) is also 0 for a multiprecision zero on this architecture, therefore comparing it to FP_ILPOGB0 does not make sense:

#include <iostream>
#include <boost/multiprecision/cpp_dec_float.hpp>

int main(int argc, char** argv) {

  boost::multiprecision::number<boost::multiprecision::cpp_dec_float<100> >
    zero("0.");

  std::cout << ilogb(zero) << std::endl;
  std::cout << FP_ILOGB0 << std::endl;

  return 0;
}

Kind regards, Thibaut.

comment:3 by John Maddock, 6 years ago

Resolution: fixed
Status: newclosed

The attached patch fixes things for cpp_dec_float, but completely breaks other types in the library (as you would quickly discover running the regression tests). This is now fixed in develop in a series of commits:

https://github.com/boostorg/multiprecision/commit/138a9055e2edc68dca2e78ff97ffe6276c17fa0a https://github.com/boostorg/multiprecision/commit/26ceb6ef386f5fb879ddccca59cc3bdc57c124f3 https://github.com/boostorg/multiprecision/commit/c0df5b6747d09268256b59501c3cab746112268e

These mostly relate to issue #12581 but fix this one as well.

Note: See TracTickets for help on using tickets.