From f92e18e6f4adb459d946ac325e052e08852cd7f4 Mon Sep 17 00:00:00 2001 From: DURAND Malo Date: Thu, 2 May 2024 04:45:40 +0200 Subject: [PATCH] adding valgrind suppressions feature --- .github/workflows/ci.yml | 8 +++++++- README.md | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ece4986..7af73b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ env: VALGRIND_REPORTS: "./valgrind-reports.log" ARTIFACTS: "${{ vars.ARTIFACTS }}" MIRROR_URL: "${{ vars.MIRROR_URL }}" + VALGRIND_SUPPRESSIONS: "${{ vars.VALGRIND_SUPPRESSIONS }}" SSH_PRIVATE_KEY: "${{ secrets.SSH_PRIVATE_KEY }}" SSH_PRIVATE_KEY_PASSPHRASE: "${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}" @@ -129,8 +130,11 @@ jobs: timeout-minutes: 1 run: "[[ $(grep -E \"^tests_run:\" Makefile) == \"\" ]] && exit 0 || make tests_run" + - name: "Creating Valgrind suppression file" + run: "echo \"${{ env.VALGRIND_SUPPRESSIONS }}\" > valgrind.supp" + - name: "Run valgrind" - run: "[ -f \"${{ env.UNIT_TESTS }}\" ] && valgrind -s --leak-check=full --track-origins=yes --read-var-info=yes --trace-children=yes --show-leak-kinds=all --read-inline-info=yes --errors-for-leak-kinds=all --track-fds=yes ${{ env.UNIT_TESTS }} 2>${{ env.VALGRIND_REPORTS }}" + run: "[ -f \"${{ env.UNIT_TESTS }}\" ] && valgrind -s --leak-check=full --track-origins=yes --read-var-info=yes --trace-children=yes --show-leak-kinds=all --read-inline-info=yes --errors-for-leak-kinds=all --track-fds=yes --show-reachable=yes --gen-suppressions=all --suppressions=valgrind.supp ${{ env.UNIT_TESTS }} 2>${{ env.VALGRIND_REPORTS }}" - name: "Analyze valgrind report" run: | @@ -149,6 +153,8 @@ jobs: fi if [[ $(echo "${line}" | grep '^==.*== .* bytes in .* blocks are definitely lost in loss record .* of .*$') ]]; then block="${line}" + elif [[ $(echo "${line}" | grep '^==.*== .* bytes in .* blocks are still reachable in loss record .* of .*$') ]]; then + block="${line}" elif [[ $(echo "${line}" | grep '^==.*== Invalid .* of size .*$') ]]; then block="${line}" elif [[ $(echo "${line}" | grep '^==.*== Open file descriptor .*: .*$') ]]; then diff --git a/README.md b/README.md index 612b79c..ef1d729 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,18 @@ I would configure my `MIRROR_URL` with the value : Please, note that the `MIRROR_URL` format is the SSH format, because the code will be pushed using your `SSH_PRIVATE_KEY` secret. +### VALGRIND_SUPPRESSIONS (optionnal) + +If during the `run-tests` rule execution you need to explicitly avoid memory +checks for a specific library or function, like the `_dl_open` calls for +instance, you can specify `Valgrind Suppressions` (check `2.5. Suppressing errors` from [Valgrind's Documentation](https://valgrind.org/docs/manual/valgrind_manual.pdf) +for more information about that.) + +Do not abuse that feature as, the more suppressions, the less efficient memory +checks are. It's just meant for some functions of the standard library which +are known to be leaks-prone. It's not meant toa void memory checks on your own +bad memory management. + ## Repository's Secrets ### SSH_PRIVATE_KEY (if MIRROR_URL is specified) @@ -114,7 +126,8 @@ look for : - memory leaks (including inside `fork()` children), - unclosed file descriptor, - invalid read/writes, -- conditionnal jumps or move depends on uninitialised value(s) +- conditionnal jumps or move depends on uninitialised value(s), +- the "still reachable" bytes ## `mirror-commits` :