From 72fec03544c82cc536bd8f59cfd237cb1e403e6f Mon Sep 17 00:00:00 2001 From: Alexandre Plateau Date: Sat, 15 Feb 2025 12:39:48 +0100 Subject: [PATCH] fix(ci): close unused file descriptors before running valgrind --- .github/workflows/ci.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72a59281..39d1c55f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -388,9 +388,22 @@ jobs: - name: Valgrind checks for memory leaks shell: bash run: | - valgrind --leak-check=full --show-leak-kinds=all \ - --track-origins=yes --track-fds=yes \ - --trace-children=yes \ + # hack to close fd 155 and 158 as github leaves them open + # thread: https://github.com/actions/runner-images/issues/3729 + # solution from: https://github.com/actions/runner-images/issues/3391#issuecomment-842139475 + if [ -d /proc/$$/fd/ ]; then + for descriptor_path in /proc/$$/fd/*; do + descriptor="$(basename "$descriptor_path")" + # Don't close stdin/stderr/stdout (-gt 2) + if [ $descriptor -gt 2 ]; then + exec {descriptor}<&- + fi + done + fi + valgrind --leak-check=full \ + --show-leak-kinds=all --show-reachable=yes \ + --track-origins=yes --track-fds=yes --trace-children=yes \ --verbose -s \ + --demangle=yes \ --error-exitcode=1 \ build/arkscript tests/unittests/resources/LangSuite/unittests.ark -L ./lib valgrind