valgrind and gmp

Niels Möller nisse at
Tue Feb 13 07:34:30 UTC 2018

tg at (Torbjörn Granlund) writes:

> Probably so.  But couldn't it be problems with valgrind and its handling
> of mpz_set_str or functions it calls, or mpz_mul, mpn_mul, mpn_mul_n,
> etc?

Possible, but somewhat unlikely. The example was from mini-gmp t-mul,
where mini-gmp mpz_mul got the correct result also under valgrind, but
the "reference" value, computed by gmp, differed with valgrind. And the
min-gmp t-add tests passed, which makes string conversion look innocent.

> Perhaps it would be better to make a self-contained test case, i.e. a
> test case which does not depend on GMP?  Just some directly assigned
> unsigned long[] vectors and a call to an included mul_basecase, and then
> printf of the (poor) result?

Calling gmp's mul_basecase has the advantage that it is likely correct
;-) But I agree it would help to use limb arrays as input and output,
with no conversions or mpz calls.

We'll see if the valgrind folks can reproduce from the given info,
otherwise I'll have to reduce the example further.


Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list