Bug in gmp/mpfr/mpc, never ending ctan computation

Richard Biener rguenther at suse.de
Mon Nov 19 09:51:31 UTC 2018


On Mon, 19 Nov 2018, Richard Biener wrote:

> 
> For
> 
> #include <complex.h>
> 
> int main()
> {
>   _Complex double x;
>   __real x = 3.09126495087690770626068115234375e+8;
>   __imag x = -4.045689747817175388336181640625e+8;
>   volatile _Complex double y = ctan (x);
>   return 0;
> }
> 
> I see GCC never finishing constant folding of ctan () with
> backtraces like
> 
> #0  0x00007ffff735666b in ?? () from /usr/lib64/libgmp.so.10
> #1  0x00007ffff7356540 in ?? () from /usr/lib64/libgmp.so.10
> #2  0x00007ffff7356540 in ?? () from /usr/lib64/libgmp.so.10
> #3  0x00007ffff7356540 in ?? () from /usr/lib64/libgmp.so.10
> #4  0x00007ffff7357157 in ?? () from /usr/lib64/libgmp.so.10
> #5  0x00007ffff7357ecf in __gmpn_mul_fft () from /usr/lib64/libgmp.so.10
> #6  0x00007ffff737a7cf in __gmpn_mulmod_bnm1 () from 
> /usr/lib64/libgmp.so.10
> #7  0x00007ffff737a553 in __gmpn_mulmod_bnm1 () from 
> /usr/lib64/libgmp.so.10
> #8  0x00007ffff737ab39 in __gmpn_mulmod_bnm1 () from 
> /usr/lib64/libgmp.so.10
> #9  0x00007ffff7358654 in __gmpn_nussbaumer_mul () from 
> /usr/lib64/libgmp.so.10
> #10 0x00007ffff735829e in __gmpn_mul_n () from /usr/lib64/libgmp.so.10
> #11 0x00007ffff737e5e9 in __gmpn_preinv_mu_div_qr ()
>    from /usr/lib64/libgmp.so.10
> #12 0x00007ffff737ebf9 in ?? () from /usr/lib64/libgmp.so.10
> #13 0x00007ffff7362638 in __gmpn_tdiv_qr () from /usr/lib64/libgmp.so.10
> #14 0x00007ffff7353e24 in __gmpn_divrem () from /usr/lib64/libgmp.so.10
> #15 0x00007ffff735b64c in ?? () from /usr/lib64/libgmp.so.10
> #16 0x00007ffff735baf5 in __gmpn_sqrtrem () from /usr/lib64/libgmp.so.10
> #17 0x00007ffff7344102 in __gmpz_sqrt () from /usr/lib64/libgmp.so.10
> #18 0x00007ffff75d4c0c in ?? () from /usr/lib64/libmpfr.so.4
> #19 0x00007ffff75d50a1 in ?? () from /usr/lib64/libmpfr.so.4
> #20 0x00007ffff75d563d in mpfr_sincos_fast () from /usr/lib64/libmpfr.so.4
> #21 0x00007ffff75d5c8c in mpfr_sin_cos () from /usr/lib64/libmpfr.so.4
> #22 0x00007ffff7810b79 in mpc_sin_cos () from /usr/lib64/libmpc.so.3
> #23 0x00007ffff78138ab in mpc_tan () from /usr/lib64/libmpc.so.3
> #24 0x0000000000e835cf in do_mpc_arg1 (result_real=0x7fffffffcee0, 
> 
> So I'm not sure which library to report the issue on (and the MPC
> bugtracker on gforge seems unused).  So I hope relevant devs follow
> the GMP list and can identify the problematic library.
> 
> This has been reported as GCC bug here: 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88074

Following up to MPC-discuss with some more info testing with
mpc 1.0.3.  When I break at

int
mpc_tan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
{
...
      /* FIXME: prevent addition overflow */
      prec += mpc_ceil_log2 (prec) + err;

I see prec (before the log2 call) increase

53
66
139
286
581
1172
...
606187

and things get slower and slower.  GCC doesn't need this
much precision for the result - it just needs 53 bits,
not sure how to communicate this or if this is already
what the result precision ends up with.

Richard.


More information about the gmp-devel mailing list