From 7fd64e8e4039dfac249e3f0991a3052bbaa24aa5 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Fri, 21 Mar 2025 16:09:49 +0100 Subject: [PATCH 01/12] Add a valgrind CI --- .github/workflows/valgrind.yml | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/valgrind.yml diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml new file mode 100644 index 000000000..1bc05e15e --- /dev/null +++ b/.github/workflows/valgrind.yml @@ -0,0 +1,57 @@ +name: valgrind +on: + push: + branches: + - "**" + tags: + - "v*" + pull_request: + branches: + - main + merge_group: + branches: + - main + workflow_dispatch: + # Weekly build on Mondays at 8 am + schedule: + - cron: "0 8 * * 1" + +jobs: + valgrind: + runs-on: ubuntu-latest + env: + VALGRIND_FLAGS: "--leak-check=full --show-leak-kinds=definite,indirect --errors-for-leak-kinds=definite,indirect --error-exitcode=1 --read-var-info=yes --track-origins=yes" + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.13 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libopenblas-dev liblapack-dev ninja-build valgrind + + - name: Install UFL branch + run: pip -v install git+https://github.com/FEniCS/ufl.git + + - name: Install Basix + run: pip -v install .[ci] --config-settings=cmake.build-type="Debug" + + - name: Run unit tests + run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/ + + - name: Run simple CMake integration test + run: | + cd test/test_cmake + cmake -DCMAKE_BUILD_TYPE=Debug -DPython3_EXECUTABLE=python3 -G Ninja -B build-dir -S . + cmake --build build-dir/ + valgrind ${VALGRIND_FLAGS} build-dir/a.out + + - name: Run Python demos + run: valrgrind ${VALGRIND_FLAGS} pytest demo/python/test.py + + - name: Run C++ demos + run: valgrind ${VALGRIND_FLAGS} pytest demo/cpp/test.py From d388597be85ee092d95c6c82499824b422e070f0 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Fri, 21 Mar 2025 16:45:45 +0100 Subject: [PATCH 02/12] Only one test file --- .github/workflows/valgrind.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 1bc05e15e..8195281d1 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -41,7 +41,7 @@ jobs: run: pip -v install .[ci] --config-settings=cmake.build-type="Debug" - name: Run unit tests - run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/ + run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/test_lagrange.py - name: Run simple CMake integration test run: | From a09f08e2ce3cf900ce34fc20a31cbaf61a76bc14 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Fri, 21 Mar 2025 16:49:28 +0100 Subject: [PATCH 03/12] typo --- .github/workflows/valgrind.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 8195281d1..6006d9ce6 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -51,7 +51,7 @@ jobs: valgrind ${VALGRIND_FLAGS} build-dir/a.out - name: Run Python demos - run: valrgrind ${VALGRIND_FLAGS} pytest demo/python/test.py + run: valgrind ${VALGRIND_FLAGS} pytest demo/python/test.py - name: Run C++ demos run: valgrind ${VALGRIND_FLAGS} pytest demo/cpp/test.py From 28519d0aedfca4c28941ac99b4255affe75522b4 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Sat, 22 Mar 2025 13:21:57 +0100 Subject: [PATCH 04/12] Add PYTHONMALLOC --- .github/workflows/valgrind.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 6006d9ce6..a47189470 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -41,17 +41,17 @@ jobs: run: pip -v install .[ci] --config-settings=cmake.build-type="Debug" - name: Run unit tests - run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/test_lagrange.py + run: PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/test_lagrange.py - name: Run simple CMake integration test run: | cd test/test_cmake cmake -DCMAKE_BUILD_TYPE=Debug -DPython3_EXECUTABLE=python3 -G Ninja -B build-dir -S . cmake --build build-dir/ - valgrind ${VALGRIND_FLAGS} build-dir/a.out + PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} build-dir/a.out - name: Run Python demos - run: valgrind ${VALGRIND_FLAGS} pytest demo/python/test.py + run: PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} pytest demo/python/test.py - name: Run C++ demos - run: valgrind ${VALGRIND_FLAGS} pytest demo/cpp/test.py + run: PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} pytest demo/cpp/test.py From eb0637ad8ba4dcae104250f318a70567353d0605 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:14:52 +0100 Subject: [PATCH 05/12] Compile valgrind ready Python --- .github/workflows/valgrind.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index a47189470..e7145e744 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -24,16 +24,24 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.13 - - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y libopenblas-dev liblapack-dev ninja-build valgrind + - uses: actions/checkout@v4 + with: + repository: 'python/cpython' + ref: 'v3.13.2' + path: 'cpython' + + - name: Build Python + working-directory: cpython + run: | + ./configure --with-valgrind + make -j4 all + sudo make install + - name: Install UFL branch run: pip -v install git+https://github.com/FEniCS/ufl.git @@ -48,7 +56,7 @@ jobs: cd test/test_cmake cmake -DCMAKE_BUILD_TYPE=Debug -DPython3_EXECUTABLE=python3 -G Ninja -B build-dir -S . cmake --build build-dir/ - PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} build-dir/a.out + valgrind ${VALGRIND_FLAGS} build-dir/a.out - name: Run Python demos run: PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} pytest demo/python/test.py From dcc33f5bfc173a8380e8956ea9a2c7084a8a6a3d Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:27:01 +0100 Subject: [PATCH 06/12] Remove PYTHONMALLOC --- .github/workflows/valgrind.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index e7145e744..bfd9ea838 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -49,7 +49,7 @@ jobs: run: pip -v install .[ci] --config-settings=cmake.build-type="Debug" - name: Run unit tests - run: PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/test_lagrange.py + run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/test_lagrange.py - name: Run simple CMake integration test run: | @@ -59,7 +59,7 @@ jobs: valgrind ${VALGRIND_FLAGS} build-dir/a.out - name: Run Python demos - run: PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} pytest demo/python/test.py + run: valgrind ${VALGRIND_FLAGS} pytest demo/python/test.py - name: Run C++ demos - run: PYTHONMALLOC=malloc valgrind ${VALGRIND_FLAGS} pytest demo/cpp/test.py + run: valgrind ${VALGRIND_FLAGS} pytest demo/cpp/test.py From f83221c5923d8259da2fd523ce33d3633276f81f Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:30:45 +0100 Subject: [PATCH 07/12] Add suppression file --- .github/workflows/valgrind.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index bfd9ea838..06081eee5 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -20,7 +20,7 @@ jobs: valgrind: runs-on: ubuntu-latest env: - VALGRIND_FLAGS: "--leak-check=full --show-leak-kinds=definite,indirect --errors-for-leak-kinds=definite,indirect --error-exitcode=1 --read-var-info=yes --track-origins=yes" + VALGRIND_FLAGS: "--suppressions=cpython/Misc/valgrind-python.supp --leak-check=full --show-leak-kinds=definite,indirect --errors-for-leak-kinds=definite,indirect --error-exitcode=1 --read-var-info=yes --track-origins=yes" steps: - uses: actions/checkout@v4 From ce70353080394241a8bf642504b8ddf305e772c8 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:35:49 +0100 Subject: [PATCH 08/12] Remove cmake integration checking --- .github/workflows/valgrind.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 06081eee5..5b24f17ba 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -51,13 +51,6 @@ jobs: - name: Run unit tests run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/test_lagrange.py - - name: Run simple CMake integration test - run: | - cd test/test_cmake - cmake -DCMAKE_BUILD_TYPE=Debug -DPython3_EXECUTABLE=python3 -G Ninja -B build-dir -S . - cmake --build build-dir/ - valgrind ${VALGRIND_FLAGS} build-dir/a.out - - name: Run Python demos run: valgrind ${VALGRIND_FLAGS} pytest demo/python/test.py From 8dbebb8134931a52935bf2e3895bbe9f87f32e8a Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:37:59 +0100 Subject: [PATCH 09/12] Retry run all --- .github/workflows/valgrind.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 5b24f17ba..463b03f70 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -49,7 +49,7 @@ jobs: run: pip -v install .[ci] --config-settings=cmake.build-type="Debug" - name: Run unit tests - run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/test_lagrange.py + run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/ - name: Run Python demos run: valgrind ${VALGRIND_FLAGS} pytest demo/python/test.py From 33fc125c4680d6430b83e63d1fe2fe1ab40c7911 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:44:46 +0100 Subject: [PATCH 10/12] Speed up valgrind --- .github/workflows/valgrind.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 463b03f70..1f9f019cd 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -20,7 +20,8 @@ jobs: valgrind: runs-on: ubuntu-latest env: - VALGRIND_FLAGS: "--suppressions=cpython/Misc/valgrind-python.supp --leak-check=full --show-leak-kinds=definite,indirect --errors-for-leak-kinds=definite,indirect --error-exitcode=1 --read-var-info=yes --track-origins=yes" + VALGRIND_FLAGS: "--suppressions=cpython/Misc/valgrind-python.supp --leak-check=full --show-leak-kinds=definite,indirect --errors-for-leak-kinds=definite,indirect --error-exitcode=1" + # Slow, but useful for in-depth info: --track-origins=yes --read-var-info=yes steps: - uses: actions/checkout@v4 From 90a6d995750bde4a445839be22c11df066c4be56 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Sun, 23 Mar 2025 14:06:35 +0100 Subject: [PATCH 11/12] Switch to RelWithDebInfo build type --- .github/workflows/valgrind.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 1f9f019cd..190744360 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -47,7 +47,7 @@ jobs: run: pip -v install git+https://github.com/FEniCS/ufl.git - name: Install Basix - run: pip -v install .[ci] --config-settings=cmake.build-type="Debug" + run: pip -v install .[ci] --config-settings=cmake.build-type="RelWithDebInfo" - name: Run unit tests run: valgrind ${VALGRIND_FLAGS} pytest -n auto --durations 20 test/ From 396da857e13df1ff72f8ea2721a71332088fbfe5 Mon Sep 17 00:00:00 2001 From: schnellerhase <56360279+schnellerhase@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:01:53 +0200 Subject: [PATCH 12/12] Switch to all leak kinds --- .github/workflows/valgrind.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index 190744360..e579c1256 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -20,7 +20,7 @@ jobs: valgrind: runs-on: ubuntu-latest env: - VALGRIND_FLAGS: "--suppressions=cpython/Misc/valgrind-python.supp --leak-check=full --show-leak-kinds=definite,indirect --errors-for-leak-kinds=definite,indirect --error-exitcode=1" + VALGRIND_FLAGS: "--suppressions=cpython/Misc/valgrind-python.supp --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=definite,indirect --error-exitcode=1" # Slow, but useful for in-depth info: --track-origins=yes --read-var-info=yes steps: - uses: actions/checkout@v4