Skip to content

Commit 0ec6aa5

Browse files
committed
Merge branch 'ep/malloc-check-perturb'
Run our test scripts with MALLOC_CHECK_ and MALLOC_PERTURB_, the built-in memory access checking facility GNU libc has. * ep/malloc-check-perturb: MALLOC_CHECK: various clean-ups Add MALLOC_CHECK_ and MALLOC_PERTURB_ libc env to the test suite for detecting heap corruption
2 parents c4eed86 + 1b3185f commit 0ec6aa5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

t/perf/perf-lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ else
4242
fi
4343

4444
TEST_NO_CREATE_REPO=t
45+
TEST_NO_MALLOC_=t
4546

4647
. ../test-lib.sh
4748

t/test-lib.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,27 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
9393
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
9494
export EDITOR
9595

96+
# Add libc MALLOC and MALLOC_PERTURB test
97+
# only if we are not executing the test with valgrind
98+
if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null ||
99+
test -n "TEST_NO_MALLOC_"
100+
then
101+
setup_malloc_check () {
102+
: nothing
103+
}
104+
teardown_malloc_check () {
105+
: nothing
106+
}
107+
else
108+
setup_malloc_check () {
109+
MALLOC_CHECK_=3 MALLOC_PERTURB_=165
110+
export MALLOC_CHECK_ MALLOC_PERTURB_
111+
}
112+
teardown_malloc_check () {
113+
unset MALLOC_CHECK_ MALLOC_PERTURB_
114+
}
115+
fi
116+
96117
# Protect ourselves from common misconfiguration to export
97118
# CDPATH into the environment
98119
unset CDPATH
@@ -302,7 +323,9 @@ test_run_ () {
302323

303324
if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
304325
then
326+
setup_malloc_check
305327
test_eval_ "$test_cleanup"
328+
teardown_malloc_check
306329
fi
307330
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
308331
then

0 commit comments

Comments
 (0)