Skip to content

Commit 067109a

Browse files
phillipwoodgitster
authored andcommitted
tests: make SANITIZE=address imply TEST_NO_MALLOC_CHECK
As the address sanitizer checks for a superset of the issues detected by setting MALLOC_CHECK_ (which tries to detect things like double frees and off-by-one errors) there is no need to set the latter when compiling with -fsanitize=address. This fixes a regression introduced by 131b94a ("test-lib.sh: Use GLIBC_TUNABLES instead of MALLOC_CHECK_ on glibc >= 2.34", 2022-03-04) which causes all the tests to fail with the message ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD. when git is compiled with SANITIZE=address on systems with glibc >= 2.34. I have tested SANITIZE=leak and SANITIZE=undefined and they do not suffer from this regression so the fix in this patch should be sufficient. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent baedc59 commit 067109a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,9 @@ PTHREAD_CFLAGS =
12211221
SPARSE_FLAGS ?= -std=gnu99
12221222
SP_EXTRA_FLAGS = -Wno-universal-initializer
12231223

1224-
# For informing GIT-BUILD-OPTIONS of the SANITIZE=leak target
1224+
# For informing GIT-BUILD-OPTIONS of the SANITIZE=leak,address targets
12251225
SANITIZE_LEAK =
1226+
SANITIZE_ADDRESS =
12261227

12271228
# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
12281229
# usually result in less CPU usage at the cost of higher peak memory.
@@ -1272,6 +1273,7 @@ SANITIZE_LEAK = YesCompiledWithIt
12721273
endif
12731274
ifneq ($(filter address,$(SANITIZERS)),)
12741275
NO_REGEX = NeededForASAN
1276+
SANITIZE_ADDRESS = YesCompiledWithIt
12751277
endif
12761278
endif
12771279

@@ -2853,6 +2855,7 @@ GIT-BUILD-OPTIONS: FORCE
28532855
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
28542856
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
28552857
@echo SANITIZE_LEAK=\''$(subst ','\'',$(subst ','\'',$(SANITIZE_LEAK)))'\' >>$@+
2858+
@echo SANITIZE_ADDRESS=\''$(subst ','\'',$(subst ','\'',$(SANITIZE_ADDRESS)))'\' >>$@+
28562859
@echo X=\'$(X)\' >>$@+
28572860
ifdef TEST_OUTPUT_DIRECTORY
28582861
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+

t/test-lib.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,10 @@ case $GIT_TEST_FSYNC in
503503
;;
504504
esac
505505

506-
# Add libc MALLOC and MALLOC_PERTURB test
507-
# only if we are not executing the test with valgrind
506+
# Add libc MALLOC and MALLOC_PERTURB test only if we are not executing
507+
# the test with valgrind and have not compiled with SANITIZE=address.
508508
if test -n "$valgrind" ||
509+
test -n "$SANITIZE_ADDRESS" ||
509510
test -n "$TEST_NO_MALLOC_CHECK"
510511
then
511512
setup_malloc_check () {

0 commit comments

Comments
 (0)