From eca92ea48cd449431cb330ab082e6a8c3b8ddc2f Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Thu, 20 May 2021 16:51:54 -0700 Subject: [PATCH] Enable some memory leak tests for standard malloc (re: 05683ec7) (#311) The memory leak regression tests added in commit 05683ec7 only leak memory in the C.UTF-8 locale if ksh is compiled with vmalloc. I've ran these regression tests against ksh93v- and neither fail in that version of ksh, which indicates the bug causing these tests to fail may be similar to the one that causes . Since the memory leak tests work with -D_std_malloc, only set $LANG to 'C' if ksh is compiled with vmalloc enabled. --- src/cmd/ksh93/tests/leaks.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cmd/ksh93/tests/leaks.sh b/src/cmd/ksh93/tests/leaks.sh index 794347829..91a815a62 100755 --- a/src/cmd/ksh93/tests/leaks.sh +++ b/src/cmd/ksh93/tests/leaks.sh @@ -29,6 +29,7 @@ if builtin vmstate 2>/dev/null && then N=512 # number of iterations for each test unit=bytes tolerance=$((4*N)) # tolerate 4 bytes per iteration to account for vmalloc artefacts + vmalloc=enabled function getmem { vmstate --format='%(busy_size)u' @@ -253,8 +254,9 @@ err_exit_if_leak 'script sourced in virtual subshell' # Multiple leaks when using arrays in functions (Red Hat #921455) # Fix based on: https://src.fedoraproject.org/rpms/ksh/blob/642af4d6/f/ksh-20120801-memlik.patch -# TODO: both of these tests still leak (although much less after the patch) when run in a non-C locale. -saveLANG=$LANG; LANG=C # comment out to test remaining leak (1/2) +# TODO: When ksh is compiled with vmalloc, both of these tests still leak (although much less +# after the patch) when run in a non-C locale. +[[ $vmalloc == enabled ]] && saveLANG=$LANG && LANG=C # comment out to test remaining leak (1/2) function _hash { @@ -282,7 +284,7 @@ done after=$(getmem) err_exit_if_leak 'indexed array in function' -LANG=$saveLANG # comment out to test remaining leak (2/2) +[[ $vmalloc == enabled ]] && LANG=$saveLANG # comment out to test remaining leak (2/2) # ====== # Memory leak in typeset (Red Hat #1036470)