Skip to content

Commit 810ac5a

Browse files
committed
Merge branch 'ep/test-malloc-check-with-glibc-2.34' into next
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.sh: Use GLIBC_TUNABLES instead of MALLOC_CHECK_ on glibc >= 2.34
2 parents 5f9d385 + 131b94a commit 810ac5a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

t/test-lib.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,25 @@ else
550550
setup_malloc_check () {
551551
MALLOC_CHECK_=3 MALLOC_PERTURB_=165
552552
export MALLOC_CHECK_ MALLOC_PERTURB_
553+
if _GLIBC_VERSION=$(getconf GNU_LIBC_VERSION 2>/dev/null) &&
554+
_GLIBC_VERSION=${_GLIBC_VERSION#"glibc "} &&
555+
expr 2.34 \<= "$_GLIBC_VERSION" >/dev/null
556+
then
557+
g=
558+
LD_PRELOAD="libc_malloc_debug.so.0"
559+
for t in \
560+
glibc.malloc.check=1 \
561+
glibc.malloc.perturb=165
562+
do
563+
g="${g#:}:$t"
564+
done
565+
GLIBC_TUNABLES=$g
566+
export LD_PRELOAD GLIBC_TUNABLES
567+
fi
553568
}
554569
teardown_malloc_check () {
555570
unset MALLOC_CHECK_ MALLOC_PERTURB_
571+
unset LD_PRELOAD GLIBC_TUNABLES
556572
}
557573
fi
558574

0 commit comments

Comments
 (0)