From 850000492cd43e40109b3a11c8613b5fff577755 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 3 May 2025 11:33:01 +0300 Subject: fixed teco_doc_undo_exchange(): use reference counting now * When popping from the Q-Register stack to local Q-Registers in macro calls, problems would arise when rubbing out that macro call since we would eventually restore a pointer that has been permanently freed along with the local Q-Registers. * Naturally this could result in everything from Valgrind warnings to crashes. * Added test case. * There is still a test case that fails when run under `--valgrind`, but it's apparently due to a glib-internal memory leak. --- tests/testsuite.at | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/testsuite.at b/tests/testsuite.at index ab1154b..dabab92 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,6 +1,8 @@ AT_INIT AT_COLOR_TESTS +# Will usually be called as +# make chek TESTSUITEFLAGS=--valgrind AT_ARG_OPTION([valgrind], AS_HELP_STRING([--valgrind], [Run tests under Valgrind (memcheck)])) @@ -10,7 +12,7 @@ AT_ARG_OPTION([valgrind], # idiom "(0/0)" to enforce a "Division by zero" error # whenever we want to fail. # -# NOTE: Square brackets are significant for M4 but +# NOTE: Square brackets are the current quote characters for M4 but # often required in TECO code as well. # We therefore use double brackets [[ ... ]] # (translated to [ ... ]) in simple cases where balanced @@ -18,6 +20,11 @@ AT_ARG_OPTION([valgrind], # quadrigraphs (@<:@ and @:>@) in all other cases. # Single round brackets also have to be replaced with the # quadrigraphs @{:@ and @:}@. +# +# FIXME: Can we use changequote() to simplify that or will it +# confuse all of Autotest's macros? +# We might also write new M4 macros that care about +# shell escaping (or writing out all test cases into files). AT_BANNER([Language features]) @@ -375,6 +382,14 @@ AT_CHECK([$SCITECO_CMDLINE '0@W{-D}C'], 0, ignore, stderr) AT_FAIL_IF([! $GREP "^Error:" stderr]) AT_CLEANUP +AT_SETUP([Rub out stack operations in macro calls]) +# This was causing memory corruptions, that would at least show up under Valgrind. +AT_CHECK([$SCITECO_CMDLINE '@^Um{[[.a]].b}Mm{-2D}'], 0, ignore, stderr) +AT_FAIL_IF([$GREP "^Error:" stderr]) +AT_CHECK([$SCITECO_CMDLINE '[[.a@^Um{]].b}Mm{-2D}'], 0, ignore, stderr) +AT_FAIL_IF([$GREP "^Error:" stderr]) +AT_CLEANUP + AT_SETUP([Searches from macro calls]) AT_CHECK([$SCITECO_CMDLINE "@^Um{:@S/XXX/} :Mm\"S(0/0)' Mm\"S(0/0)'"], 0, ignore, stderr) AT_FAIL_IF([$GREP "^Error:" stderr]) -- cgit v1.2.3