Comment 11 for bug 1745188

Revision history for this message
Raghavan Santhanam (geekie12) wrote :

<< reposting my previous comment in the aligned format as there seems to
be no option to edit it >>

Hello,

I encountered this abort/crash with gnome-calculator and finally got rid
of it as under.

I manually built and installed the latest mpfr/mpfc/gmp source code and
binaries for building gcc-7.3 which turned out to be extremely
frustrating and energy-draining. So, after installing those hand-built
mpfr/mpfc/gmp binaries, I happened to launch the calculator(gnome-
calculator) from the quick launch side-bar(yes, I still have Unity on
17.10!) and its icon was animating as usual for few seconds and nothing
was happening after that. So, I tried to launch it from terminal - it
showed the abort/crash error that this bug reports :
"../../src/init2.c:52: MPFR assertion failed: p >= 2 && p <= ((mpfr_prec_t)((mpfr_uprec_t)(~(mpfr_uprec_t)0)>>1))".

After searching for the above error, I stumbled upon this bug report, and
I tried to downgrade back to the default Ubuntu-repo version via "apt
install" - that didn't solve the issue. I tried to build and install
mpfr-4.0.0 version - didn't change the crash behavior.

Tried building and installing mpfr-3.1.6/5 - didn't work. Manually
removed the installed libraries(libmpfr*) from /usr/lib/* and /usr/local
/lib/* and redid the installation - both "apt install" and build-install
method from source for the reported mpfr-3.1.6 - didn't help. I had also
tried to modify mpfr-4.0.1's source code to use precision 2 instead of 1
and also bunch of the other assert-macros logic for disabling the
assertion(abort) - didn't help.

Downgraded mpc* as well as gmp* to older versions by building from their
sources and installing them - didn't help.

So, basically, I tried to put my system back to the previous state before
I started meddling with the mpfr/gmp/mpc all for building gcc-7.3 from
its source - huge cost paid!

Tried the extreme cases out though not relevant as I could already figure
out but did them anyway to get back the "calculator" : reinstalled the
kernel(I know kernel has nothing to do with mpfr!), rebooted the PC, and
so on - didn't help.

Finally, I paid close attention to the error stating that this assertion
was from "init2.c:52", so I located this 52nd source code line inside
mpfr-3.1.6/src/init2.c and *disabled* the assertion by commenting it out
as my last attempt to get back the system to successfully launch gnome
-calculator, rebuilt and installed it - boom! I got the gnome-calculator
back.

Below is what I commented out. I thought this was not necessary as
MPFR_PREC_MIN was already 2 and not 1 as mentioned here in this proposed
bug report/fix. Anyway.

<snip>
  /* p=1 is not allowed since the rounding to nearest even rule requires at
     least two bits of mantissa: the neighbours of 3/2 are 1*2^0 and 1*2^1,
     which both have an odd mantissa */
  //MPFR_ASSERTN(p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX);
</snip>

I confirmed that MPFR_PREC_MIN was 2 as told in here in this bug report
and not 1 as in 4.0.1. But, even then the above assertion was failing
causing abort/crash for gnome-calculator. Below is what I have in
mpfr-3.1.6/src/mpfr.h(unchanged).

<snip>
/* Definition of precision limits without needing <limits.h> */
/* Note: the casts allows the expression to yield the wanted behavior
   for _MPFR_PREC_FORMAT == 1 (due to integer promotion rules). */
#define MPFR_PREC_MIN 2
#define MPFR_PREC_MAX ((mpfr_prec_t)((mpfr_uprec_t)(~(mpfr_uprec_t)0)>>1))
</snip>

Hope my above change help those banging their head to fix this super
-annoying crash, until it's fixed in the mpfr* codebase/release as needed.

Cheers,
Raghavan