From eb3135b9b6b242ca33427dbf4fb2c9aa75031705 Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 14 Jun 2024 21:11:59 +0800 Subject: [PATCH 1/6] Enable TSAN check on macOS with free-threads build --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 750aa1ed87bca1..28d77ab11c98a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -500,6 +500,7 @@ jobs: options: ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug suppressions_path: Tools/tsan/suppressions_free_threading.txt tsan_logs_artifact_name: tsan-logs-free-threading + os-matrix: '["ubuntu-22.04", "macos-14"]' # CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/ cifuzz: From b86782ea35331d994a7b4aa8c84534cf2de3cca0 Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 14 Jun 2024 21:23:28 +0800 Subject: [PATCH 2/6] fix tsan --- .github/workflows/reusable-tsan.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-tsan.yml b/.github/workflows/reusable-tsan.yml index b6d5d8fa1c7157..f5f1a814037dfa 100644 --- a/.github/workflows/reusable-tsan.yml +++ b/.github/workflows/reusable-tsan.yml @@ -15,12 +15,19 @@ on: description: 'Name of the TSAN logs artifact. Must be unique for each job.' required: true type: string + os-matrix: + required: false + type: string + default: '["ubuntu-22.04"]' jobs: build_tsan_reusable: - name: 'Thread sanitizer' - runs-on: ubuntu-22.04 + name: 'Thread sanitizer (${{ matrix.os }})' + runs-on: ${{ matrix.os }} timeout-minutes: 60 + strategy: + matrix: + os: ${{fromJson(inputs.os-matrix)}} steps: - uses: actions/checkout@v4 - name: Runner image version From 0fcc95214333902c31a7f4a62fc0b5ae4e2840f7 Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 14 Jun 2024 21:35:58 +0800 Subject: [PATCH 3/6] skip install dependencies on macos in tsan --- .github/workflows/reusable-tsan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/reusable-tsan.yml b/.github/workflows/reusable-tsan.yml index f5f1a814037dfa..2129a471d90ad7 100644 --- a/.github/workflows/reusable-tsan.yml +++ b/.github/workflows/reusable-tsan.yml @@ -38,6 +38,7 @@ jobs: path: config.cache key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }} - name: Install Dependencies + if: ${{ startsWith(matrix.os, 'ubuntu') }} run: | sudo ./.github/workflows/posix-deps-apt.sh # Install clang-18 From 3136d758140bdcf760c6bd7f370e41dc2da4ee89 Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 14 Jun 2024 21:44:48 +0800 Subject: [PATCH 4/6] using different binary name for tsan test on macos --- .github/workflows/reusable-tsan.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/reusable-tsan.yml b/.github/workflows/reusable-tsan.yml index 2129a471d90ad7..0f81fadc39da6b 100644 --- a/.github/workflows/reusable-tsan.yml +++ b/.github/workflows/reusable-tsan.yml @@ -72,6 +72,10 @@ jobs: run: make pythoninfo - name: Tests run: ./python -m test --tsan -j4 + if: ${{ startsWith(matrix.os, 'ubuntu') }} + - name: Tests + run: ./python.exe -m test --tsan -j4 + if: ${{ startsWith(matrix.os, 'maxos') }} - name: Display TSAN logs if: always() run: find ${GITHUB_WORKSPACE} -name 'tsan_log.*' | xargs head -n 1000 From 3cf67e85ba78e50e6f3609de2fa3a8b9f72a4da8 Mon Sep 17 00:00:00 2001 From: AN Long Date: Fri, 14 Jun 2024 21:50:16 +0800 Subject: [PATCH 5/6] fix typo --- .github/workflows/reusable-tsan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-tsan.yml b/.github/workflows/reusable-tsan.yml index 0f81fadc39da6b..5ff0a9d0e23045 100644 --- a/.github/workflows/reusable-tsan.yml +++ b/.github/workflows/reusable-tsan.yml @@ -75,7 +75,7 @@ jobs: if: ${{ startsWith(matrix.os, 'ubuntu') }} - name: Tests run: ./python.exe -m test --tsan -j4 - if: ${{ startsWith(matrix.os, 'maxos') }} + if: ${{ startsWith(matrix.os, 'macos') }} - name: Display TSAN logs if: always() run: find ${GITHUB_WORKSPACE} -name 'tsan_log.*' | xargs head -n 1000 From 9301018d49d6456a10a12af0f0997a886e50c285 Mon Sep 17 00:00:00 2001 From: AN Long Date: Tue, 18 Jun 2024 22:29:57 +0800 Subject: [PATCH 6/6] skip some tests --- Lib/test/test_capi/test_mem.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_capi/test_mem.py b/Lib/test/test_capi/test_mem.py index 6ab7b685c2e18b..0c2963cf6fa8c6 100644 --- a/Lib/test/test_capi/test_mem.py +++ b/Lib/test/test_capi/test_mem.py @@ -1,8 +1,8 @@ import re +import sys import textwrap import unittest - from test import support from test.support import import_helper, requires_subprocess from test.support.script_helper import assert_python_failure, assert_python_ok @@ -75,12 +75,20 @@ def check_malloc_without_gil(self, code): def test_pymem_malloc_without_gil(self): # Debug hooks must raise an error if PyMem_Malloc() is called # without holding the GIL + if support.check_sanitizer(thread=True) and sys.platform == 'darwin': + # See: gh-120696 + raise unittest.SkipTest("this test will hang on macOS with TSAN") + code = 'import _testcapi; _testcapi.pymem_malloc_without_gil()' self.check_malloc_without_gil(code) def test_pyobject_malloc_without_gil(self): # Debug hooks must raise an error if PyObject_Malloc() is called # without holding the GIL + if support.check_sanitizer(thread=True) and sys.platform == 'darwin': + # See: gh-120696 + raise unittest.SkipTest("this test will hang on macOS with TSAN") + code = 'import _testcapi; _testcapi.pyobject_malloc_without_gil()' self.check_malloc_without_gil(code)