Skip to content

Commit

Permalink
adding valgrind suppressions feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Ximaz committed May 2, 2024
1 parent fff1982 commit f92e18e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down Expand Up @@ -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: |
Expand All @@ -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
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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` :

Expand Down

0 comments on commit f92e18e

Please sign in to comment.