From f99ea8ba900ede06134e5fc7e814a70b10fe841f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 9 May 2024 15:06:40 +0200 Subject: [PATCH] free tests: Avoid test failure with ASAN. * tests/test-free.c (main): Skip mmap/munmap based test if ASAN is enabled. --- ChangeLog | 6 ++++++ tests/test-free.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 90c43861d6..aec539e3e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-05-09 Bruno Haible + + free tests: Avoid test failure with ASAN. + * tests/test-free.c (main): Skip mmap/munmap based test if ASAN is + enabled. + 2024-05-09 Bruno Haible explicit_bzero, memset_explicit tests: Avoid test failures with ASAN. diff --git a/tests/test-free.c b/tests/test-free.c index c530e861e2..9cc0c7016c 100644 --- a/tests/test-free.c +++ b/tests/test-free.c @@ -1,5 +1,5 @@ /* Test of free() function. - Copyright (C) 2020-2023 Free Software Foundation, Inc. + Copyright (C) 2020-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -98,6 +98,12 @@ main () #undef N } + /* Skip this test when an address sanitizer is in use, because it would report + a "heap buffer overflow". */ + #ifndef __has_feature + #define __has_feature(a) 0 + #endif + #if !(defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)) /* Test a less common code path. When malloc() is based on mmap(), free() can sometimes call munmap(). munmap() usually succeeds, but fails in a particular situation: when @@ -170,6 +176,7 @@ main () } } #endif + #endif return 0; } -- 2.39.5