@@ -577,53 +577,6 @@ case $GIT_TEST_FSYNC in
577577 ;;
578578esac
579579
580- # Add libc MALLOC and MALLOC_PERTURB test only if we are not executing
581- # the test with valgrind and have not compiled with conflict SANITIZE
582- # options.
583- if test -n " $valgrind " ||
584- test -n " $SANITIZE_ADDRESS " ||
585- test -n " $SANITIZE_LEAK " ||
586- test -n " $TEST_NO_MALLOC_CHECK "
587- then
588- setup_malloc_check () {
589- : nothing
590- }
591- teardown_malloc_check () {
592- : nothing
593- }
594- else
595- _USE_GLIBC_TUNABLES=
596- if _GLIBC_VERSION=$( getconf GNU_LIBC_VERSION 2> /dev/null) &&
597- _GLIBC_VERSION=${_GLIBC_VERSION# " glibc " } &&
598- expr 2.34 \< = " $_GLIBC_VERSION " > /dev/null
599- then
600- _USE_GLIBC_TUNABLES=YesPlease
601- fi
602- setup_malloc_check () {
603- local g
604- local t
605- MALLOC_CHECK_=3 MALLOC_PERTURB_=165
606- export MALLOC_CHECK_ MALLOC_PERTURB_
607- if test -n " $_USE_GLIBC_TUNABLES "
608- then
609- g=
610- LD_PRELOAD=" libc_malloc_debug.so.0"
611- for t in \
612- glibc.malloc.check=1 \
613- glibc.malloc.perturb=165
614- do
615- g=" ${g#: } :$t "
616- done
617- GLIBC_TUNABLES=$g
618- export LD_PRELOAD GLIBC_TUNABLES
619- fi
620- }
621- teardown_malloc_check () {
622- unset MALLOC_CHECK_ MALLOC_PERTURB_
623- unset LD_PRELOAD GLIBC_TUNABLES
624- }
625- fi
626-
627580# Protect ourselves from common misconfiguration to export
628581# CDPATH into the environment
629582unset CDPATH
@@ -1483,6 +1436,56 @@ GIT_ATTR_NOSYSTEM=1
14831436GIT_CEILING_DIRECTORIES=" $TRASH_DIRECTORY /.."
14841437export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM GIT_CEILING_DIRECTORIES
14851438
1439+ # Add libc MALLOC and MALLOC_PERTURB test only if we are not executing
1440+ # the test with valgrind and have not compiled with conflict SANITIZE
1441+ # options.
1442+ if test -n " $valgrind " ||
1443+ test -n " $SANITIZE_ADDRESS " ||
1444+ test -n " $SANITIZE_LEAK " ||
1445+ test -n " $TEST_NO_MALLOC_CHECK "
1446+ then
1447+ setup_malloc_check () {
1448+ : nothing
1449+ }
1450+ teardown_malloc_check () {
1451+ : nothing
1452+ }
1453+ else
1454+ _USE_GLIBC_TUNABLES=
1455+ _USE_GLIBC_PRELOAD=libc_malloc_debug.so.0
1456+ if _GLIBC_VERSION=$( getconf GNU_LIBC_VERSION 2> /dev/null) &&
1457+ _GLIBC_VERSION=${_GLIBC_VERSION# " glibc " } &&
1458+ expr 2.34 \< = " $_GLIBC_VERSION " > /dev/null &&
1459+ stderr=$( LD_PRELOAD=$_USE_GLIBC_PRELOAD git version 2>&1 > /dev/null) &&
1460+ test -z " $stderr "
1461+ then
1462+ _USE_GLIBC_TUNABLES=YesPlease
1463+ fi
1464+ setup_malloc_check () {
1465+ local g
1466+ local t
1467+ MALLOC_CHECK_=3 MALLOC_PERTURB_=165
1468+ export MALLOC_CHECK_ MALLOC_PERTURB_
1469+ if test -n " $_USE_GLIBC_TUNABLES "
1470+ then
1471+ g=
1472+ LD_PRELOAD=$_USE_GLIBC_PRELOAD
1473+ for t in \
1474+ glibc.malloc.check=1 \
1475+ glibc.malloc.perturb=165
1476+ do
1477+ g=" ${g#: } :$t "
1478+ done
1479+ GLIBC_TUNABLES=$g
1480+ export LD_PRELOAD GLIBC_TUNABLES
1481+ fi
1482+ }
1483+ teardown_malloc_check () {
1484+ unset MALLOC_CHECK_ MALLOC_PERTURB_
1485+ unset LD_PRELOAD GLIBC_TUNABLES
1486+ }
1487+ fi
1488+
14861489if test -z " $GIT_TEST_CMP "
14871490then
14881491 if test -n " $GIT_TEST_CMP_USE_COPIED_CONTEXT "
0 commit comments