From 847811d6ab9559cbfd4006e1d94a2cdee556c095 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Thu, 30 Oct 2014 13:30:15 +0000 Subject: [src/get_str.c] Added some logging (MPFR_LOG_*), which triggers a crash in tget_str with MPFR_LOG_ALL=1. An analysis with gdb shows that this is due to an invalid MPFR number in mpfr_ceil_mul(). Added a MPFR_ASSERTD (mpfr_check (p)); there, which fails in tget_str (this was the cause of the crash), even without logging. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9222 280ebfd0-de03-0410-8827-d642c229c3f4 --- src/get_str.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/get_str.c b/src/get_str.c index b9665480b..7eff2f519 100644 --- a/src/get_str.c +++ b/src/get_str.c @@ -2218,6 +2218,7 @@ mpfr_ceil_mul (mpfr_exp_t e, int beta, int i) mpfr_exp_t r; p = &__gmpfr_l2b[beta-2][i]; + MPFR_ASSERTD (mpfr_check (p)); mpfr_init2 (t, sizeof (mpfr_exp_t) * CHAR_BIT); mpfr_set_exp_t (t, e, MPFR_RNDU); mpfr_mul (t, t, p, MPFR_RNDU); @@ -2265,6 +2266,11 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x, /* if exact = 1 then err is undefined */ /* otherwise err is such that |x*b^(m-g)-a*2^exp_a| < 2^(err+exp_a) */ + MPFR_LOG_FUNC + (("b=%d m=%zu x[%Pu]=%.*Rg rnd=%d", + b, m, mpfr_get_prec (x), mpfr_log_prec, x, rnd), + ("flags=%lx", (unsigned long) __gmpfr_flags)); + /* is the base valid? */ if (b < 2 || b > 62) return NULL; @@ -2276,6 +2282,7 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x, if (s == NULL) s = (char *) (*__gmp_allocate_func) (6); strcpy (s, "@NaN@"); + MPFR_LOG_MSG (("%s\n", s)); __gmpfr_flags |= MPFR_FLAGS_NAN; return s; } @@ -2287,6 +2294,7 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x, if (s == NULL) s = (char *) (*__gmp_allocate_func) (neg + 6); strcpy (s, (neg) ? "-@Inf@" : "@Inf@"); + MPFR_LOG_MSG (("%s\n", s)); return s; } @@ -2309,6 +2317,8 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x, m = 2; } + MPFR_LOG_MSG (("m=%zu\n", m)); + /* the code below for non-power-of-two bases works for m=1 */ MPFR_ASSERTN (m >= 2 || (!IS_POW2(b) && m >= 1)); @@ -2399,6 +2409,8 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x, /* the exponent of s is f + 1 */ *e = f + 1; + MPFR_LOG_MSG (("e=%" MPFR_EXP_FSPEC "d\n", (mpfr_eexp_t) *e)); + MPFR_TMP_FREE (marker); MPFR_SAVE_EXPO_FREE (expo); return s0; @@ -2551,6 +2563,8 @@ mpfr_get_str (char *s, mpfr_exp_t *e, int b, size_t m, mpfr_srcptr x, *e += g; + MPFR_LOG_MSG (("e=%" MPFR_EXP_FSPEC "d\n", (mpfr_eexp_t) *e)); + MPFR_TMP_FREE (marker); MPFR_SAVE_EXPO_FREE (expo); return s0; -- cgit v1.2.1