Running a testdir created with gnulib-tool option '--with-longrunning-tests'
on Solaris 11 OmniOS, I see the test-vasnprintf-big test fail:

abort at test-vasnprintf-big.c:125

I don't have gdb on that machine. So I reproduced it on Solaris 11 OpenIndiana
from 2017. Here, I see the test failure outside of gdb, but no failure
under gdb. Which smells like uninitialized values or data...

So I transported the Solaris 11 OpenIndiana configuration results
(`grep printf config.cache`) to a Linux machine, recompiled the testdir
there, and ran the test under valgrind. valgrind reported:

==2134082== Conditional jump or move depends on uninitialised value(s)
==2134082==    at 0x4855178: strlen (vg_replace_strmem.c:506)
==2134082==    by 0x402F80: vasnprintf (vasnprintf.c:3137)
==2134082==    by 0x40273E: asnprintf (asnprintf.c:29)
==2134082==    by 0x401689: main (test-vasnprintf-big.c:116)

Bingo! Here's the fix:


2026-07-14  Bruno Haible  <[email protected]>

        vasnprintf-extra-tests: Fix test bug.
        * tests/test-vasnprintf-big.c (main): Properly NUL-terminate the second
        string.

diff --git a/tests/test-vasnprintf-big.c b/tests/test-vasnprintf-big.c
index a9969e18c7..1ff043a105 100644
--- a/tests/test-vasnprintf-big.c
+++ b/tests/test-vasnprintf-big.c
@@ -110,7 +110,7 @@ main ()
             if (s2 != NULL)
               {
                 memset (s2, 'b', n2);
-                s1[n1] = '\0';
+                s2[n2] = '\0';
 
                 size_t len;
                 char *s = asnprintf (NULL, &len, "x%sy%sz", s1, s2);




Reply via email to