test-free failure

Bruno Haible via Gnulib discussion list <[email protected]> Sat, 01 Aug 2026 09:08:17 +0200
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <25230719.6Emhk5qWAg@cagnes>
In a CI run of GNU m4 on Ubuntu 24.04, I see a test failure:

../../../sources/m4/build-aux/test-driver: line 112: 21920 Aborted                 (core dumped) "$@" >> "$log_file" 2>&1
FAIL: test-free

I reproduce it locally:

  $ ./test-free
  *** buffer overflow detected ***: terminated
  Aborted (core dumped)

Without -O2, it works fine. So, it looks like a gcc 13.3.0-ubuntu bug to me.
(Which I don't reproduce with gcc 13.3.0 or 13.4.0 on Ubuntu 26.04.)
Anyway, here's the workaround:



2026-08-01  Bruno Haible  <[email protected]>

	free-posix tests: Avoid failure on Ubuntu 24.04 (regression 2026-07-28).
	* tests/test-free.c (main): Restore previous code for !__FILC__.

diff --git a/tests/test-free.c b/tests/test-free.c
index 7a3fa9a9aa..612a7afb7f 100644
--- a/tests/test-free.c
+++ b/tests/test-free.c
@@ -131,7 +131,12 @@ main ()
           /* Do a large memory allocation.  */
           size_t big_size = 0x1000000;
           void *ptr = malloc (big_size - 0x100);
-          char *ptr_aligned = (char *) ptr - ((uintptr_t) ptr & (pagesize - 1));
+          char *ptr_aligned;
+          #if defined __FILC__
+          ptr_aligned = (char *) ptr - ((uintptr_t) ptr & (pagesize - 1));
+          #else
+          ptr_aligned = (char *) ((uintptr_t) ptr & ~(pagesize - 1));
+          #endif
           /* This large memory allocation allocated a memory area
              from ptr_aligned to ptr_aligned + big_size.
              Enlarge this memory area by adding a page before and a page