Valgrind reports use of uninitialised value for __gmpz_powm_sec on i686 host

Torbjörn Granlund tg at
Mon Aug 28 18:27:05 CEST 2023

Trevor Spiteri <tspiteri at> writes:

  Valgrind is reporting the use of uninitialised value(s) in
  __gmpz_powm_sec for i686 host, though I found no similar issue for
  x86_64 host. This issue started in 6.3.0, and was not there for 6.2.1.

I tried this, and it looks like a valgrind bug rather than a GMP bug.

I inserted a print of the single-limb result in mpz/powm_sec.c, just
after the call to mpn_powm_sec.  The result is 9 as expected, but
valgrind claims that 9 is not initialised.

Quite extraordinary that the result can be correct while valgrind says
nobody generated any result.

I also wrote well-defined garbage to that same location before the
mpn_sec_powm call.  That proves that the 9 just didn't happen to be
there, but that mpn_sec_powm wrote it there.  Still valgrind thinks the
location is not well-defined.

Possibly, valgrind tracks something which it thinks is not well-defined,
but that the error becomes delayed?

(I cannot reproduce this for a 64-bit build.)

Please encrypt, key id 0xC8601622

More information about the gmp-bugs mailing list