[PATCH v2] Use correct type for glibc.malloc.perturb in tst-tunconf1.c

Stefan Liebler stli@linux.ibm.com
Mon Jul 13 08:31:53 GMT 2026


On s390x the test elf/tunconf1 fails with:
tst-tunconf1.c:41: numeric comparison failure (widths 64 and 32)
   left: 180388626436 (0x2a00000004); from: (long)perturb
  right: 42 (0x2a); from: 42

According to elf/dl-tunables.list, glibc.malloc.perturb is of type int32_t (4byte)
and not size_t (8byte) which was used for TUNABLE_GET_FULL inside the testcase.
Therefore the correct 32bit value 0x2a=42 is written to the to the wrong place
and leads to the comparison failure.

The printf format specifiers for size_t were also adjusted.
---
 elf/tst-tunconf1.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/elf/tst-tunconf1.c b/elf/tst-tunconf1.c
index 74f596d913..227314182a 100644
--- a/elf/tst-tunconf1.c
+++ b/elf/tst-tunconf1.c
@@ -16,6 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <support/check.h>
 
@@ -26,28 +27,28 @@ do_test (void)
 {
   size_t tcache_count = TUNABLE_GET_FULL (glibc, malloc, tcache_count, size_t, NULL);
   size_t tcache_max = TUNABLE_GET_FULL (glibc, malloc, tcache_max, size_t, NULL);
-  size_t perturb = TUNABLE_GET_FULL (glibc, malloc, perturb, size_t, NULL);
+  int32_t perturb = TUNABLE_GET_FULL (glibc, malloc, perturb, int32_t, NULL);
   size_t mmap_threshold = TUNABLE_GET_FULL (glibc, malloc, mmap_threshold, size_t, NULL);
   size_t trim_threshold = TUNABLE_GET_FULL (glibc, malloc, trim_threshold, size_t, NULL);
 
-  printf("tcache count is %ld (should be 5, from env)\n", (long)tcache_count);
+  printf("tcache count is %zu (should be 5, from env)\n", tcache_count);
   TEST_COMPARE ((long)tcache_count, 5);
-  printf("tcache max is %ld (should be 4, from /etc)\n", (long)tcache_max);
+  printf("tcache max is %zu (should be 4, from /etc)\n", tcache_max);
   TEST_COMPARE ((long)tcache_max, 4);
 
   /* This is set by the environment but blocked by the config.  */
-  printf("perturb is %ld (should be 42, from /etc)\n",
-	 (long)perturb);
-  TEST_COMPARE ((long)perturb, 42);
+  printf("perturb is %" PRId32 " (should be 42, from /etc)\n",
+	 perturb);
+  TEST_COMPARE (perturb, 42);
 
   /* This is blocked by the general config, enabled by filter, set in env.  */
-  printf("mmap_threshold is %ld (should be 10002, from env)\n",
-	 (long)mmap_threshold);
+  printf("mmap_threshold is %zu (should be 10002, from env)\n",
+	 mmap_threshold);
   TEST_COMPARE ((long)mmap_threshold, 10002);
 
   /* This is allowed by the general config, blocked by filter, set in env.  */
-  printf("trim_threshold is %ld (should be 10001, from filter)\n",
-	 (long)trim_threshold);
+  printf("trim_threshold is %zu (should be 10001, from filter)\n",
+	 trim_threshold);
   TEST_COMPARE ((long)trim_threshold, 10001);
 
   return 0;
-- 
2.54.0



More information about the Libc-alpha mailing list