Undefined behavior in t-sqrlo test
bodrato at mail.dm.unipi.it
Fri Sep 20 18:51:11 UTC 2019
Il Ven, 20 Settembre 2019 5:33 pm, Andrew Wock ha scritto:
> The t-sqrlo test invokes undefined behavior.
Yes, also Valgrind detects it...
> The mpn_ptr scratch as well as the boundary values of the mpn_ptr pp are
> uninitialized values.
Not exactly, only scratch is uninitialised.
> I was able to get the tests to pass by simply memset()ting scratch to any
The simpler workaround consists in activating the code that is available
in the source, but was disabled by the author (me!) for some unknown
I pushed the following:
--- a/tests/mpn/t-sqrlo.c Mon Sep 16 22:18:22 2019 +0200
+++ b/tests/mpn/t-sqrlo.c Fri Sep 20 20:20:09 2019 +0200
@@ -83,10 +83,8 @@
p_after = pp[n];
itch = mpn_sqrlo_itch (n);
ASSERT_ALWAYS (itch <= mpn_sqrlo_itch (MAX_N));
mpn_random2 (scratch-1, itch+2);
s_before = scratch[-1];
s_after = scratch[itch];
More information about the gmp-bugs