From a2acb6d7aa1772ee9377cebecaa912fd36b9e9c3 Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Sat, 29 Nov 2025 01:10:26 +0300 Subject: [PATCH] tests/functional: Work around stack overflows under ASAN in doc-functor tests This was failing under ASAN in https://hydra.nixos.org/build/315173638/nixlog/1. ASAN uses a bit more stack space and the default max call depth is not enough. Not sure what's so special about this particular test. --- tests/functional/repl.sh | 10 +++++++--- tests/functional/repl/doc-functor.expected | 4 ++-- tests/functional/repl/doc-functor.flags | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 tests/functional/repl/doc-functor.flags diff --git a/tests/functional/repl.sh b/tests/functional/repl.sh index aeff43d30..7023f2b8a 100755 --- a/tests/functional/repl.sh +++ b/tests/functional/repl.sh @@ -350,10 +350,9 @@ runRepl () { local testDirNoUnderscores testDirNoUnderscores="${testDir//_/}" - # TODO: pass arguments to nix repl; see lang.sh _NIX_TEST_RAW_MARKDOWN=1 \ _NIX_TEST_REPL_ECHO=1 \ - nix repl 2>&1 \ + nix repl "$@" 2>&1 \ | stripColors \ | tr -d '\0' \ | stripEmptyLinesBeforePrompt \ @@ -373,7 +372,12 @@ for test in $(cd "$testDir/repl"; echo *.in); do in="$testDir/repl/$test.in" actual="$TEST_ROOT/$test.actual" expected="$testDir/repl/$test.expected" - (cd "$testDir/repl"; set +x; runRepl 2>&1) < "$in" > "$actual" || { + declare -a flags=() + if test -e "$testDir/repl/$test.flags"; then + read -r -a flags < "$testDir/repl/$test.flags" + fi + + (cd "$testDir/repl"; set +x; runRepl "${flags[@]}" 2>&1) < "$in" > "$actual" || { echo "FAIL: $test (exit code $?)" >&2 badExitCode=1 } diff --git a/tests/functional/repl/doc-functor.expected b/tests/functional/repl/doc-functor.expected index 503fb8073..8b86fe913 100644 --- a/tests/functional/repl/doc-functor.expected +++ b/tests/functional/repl/doc-functor.expected @@ -43,7 +43,7 @@ error: | ^ 91| }; - (19999 duplicate frames omitted) + (199 duplicate frames omitted) error: stack overflow; max-call-depth exceeded at /path/to/tests/functional/repl/doc-functor.nix:90:23: @@ -56,7 +56,7 @@ nix-repl> :doc diverging error: … while partially calling '__functor' to retrieve documentation - (10000 duplicate frames omitted) + (100 duplicate frames omitted) … while calling '__functor' at /path/to/tests/functional/repl/doc-functor.nix:103:21: diff --git a/tests/functional/repl/doc-functor.flags b/tests/functional/repl/doc-functor.flags new file mode 100644 index 000000000..493088430 --- /dev/null +++ b/tests/functional/repl/doc-functor.flags @@ -0,0 +1 @@ +--max-call-depth 100