Skip to content

Commit b6763af

Browse files
committed
Merge branch 'ep/test-malloc-check-with-glibc-2.34'
The method to trigger malloc check used in our tests no longer work with newer versions of glibc. * ep/test-malloc-check-with-glibc-2.34: test-lib: declare local variables as local test-lib.sh: Use GLIBC_TUNABLES instead of MALLOC_CHECK_ on glibc >= 2.34
2 parents 964a856 + baedc59 commit b6763af

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

t/test-lib.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,29 @@ then
548548
}
549549
else
550550
setup_malloc_check () {
551+
local g
552+
local t
551553
MALLOC_CHECK_=3 MALLOC_PERTURB_=165
552554
export MALLOC_CHECK_ MALLOC_PERTURB_
555+
if _GLIBC_VERSION=$(getconf GNU_LIBC_VERSION 2>/dev/null) &&
556+
_GLIBC_VERSION=${_GLIBC_VERSION#"glibc "} &&
557+
expr 2.34 \<= "$_GLIBC_VERSION" >/dev/null
558+
then
559+
g=
560+
LD_PRELOAD="libc_malloc_debug.so.0"
561+
for t in \
562+
glibc.malloc.check=1 \
563+
glibc.malloc.perturb=165
564+
do
565+
g="${g#:}:$t"
566+
done
567+
GLIBC_TUNABLES=$g
568+
export LD_PRELOAD GLIBC_TUNABLES
569+
fi
553570
}
554571
teardown_malloc_check () {
555572
unset MALLOC_CHECK_ MALLOC_PERTURB_
573+
unset LD_PRELOAD GLIBC_TUNABLES
556574
}
557575
fi
558576

0 commit comments

Comments
 (0)