Skip to content

Commit bd5e85a

Browse files
committed
pythongh-112536: Set up TSAN CI for free-threading
1 parent 5b2f21f commit bd5e85a

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

.github/workflows/build.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,64 @@ jobs:
472472
- name: Tests
473473
run: xvfb-run make test
474474

475+
build_tsan_free_threading:
476+
name: 'Thread sanitizer (free-threading)'
477+
runs-on: ubuntu-20.04
478+
timeout-minutes: 60
479+
needs: check_source
480+
if: needs.check_source.outputs.run_tests == 'true'
481+
env:
482+
OPENSSL_VER: 3.0.13
483+
PYTHONSTRICTEXTENSIONBUILD: 1
484+
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
485+
steps:
486+
- uses: actions/checkout@v4
487+
- name: Runner image version
488+
run: echo "IMAGE_VERSION=${ImageVersion}" >> $GITHUB_ENV
489+
- name: Restore config.cache
490+
uses: actions/cache@v4
491+
with:
492+
path: config.cache
493+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}
494+
- name: Register gcc problem matcher
495+
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
496+
- name: Install Dependencies
497+
run: sudo ./.github/workflows/posix-deps-apt.sh
498+
- name: Set up GCC-10 for TSAN
499+
uses: egor-tensin/setup-gcc@v1
500+
with:
501+
version: 10
502+
- name: Configure OpenSSL env vars
503+
run: |
504+
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV
505+
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> $GITHUB_ENV
506+
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
507+
- name: 'Restore OpenSSL build'
508+
id: cache-openssl
509+
uses: actions/cache@v4
510+
with:
511+
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
512+
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
513+
- name: Install OpenSSL
514+
if: steps.cache-openssl.outputs.cache-hit != 'true'
515+
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux
516+
- name: Add ccache to PATH
517+
run: |
518+
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
519+
- name: Configure ccache action
520+
uses: hendrikmuhs/[email protected]
521+
with:
522+
save: ${{ github.event_name == 'push' }}
523+
max-size: "200M"
524+
- name: Configure CPython
525+
run: ./configure --config-cache --with-thread-sanitizer --disable-gil
526+
- name: Build CPython
527+
run: make -j4
528+
- name: Display build info
529+
run: make pythoninfo
530+
- name: Tests
531+
run: xvfb-run make test
532+
475533
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
476534
cifuzz:
477535
name: CIFuzz

configure

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,6 +3264,12 @@ AC_MSG_RESULT([no])
32643264
with_tsan="no"
32653265
])
32663266

3267+
if test "$with_tsan" = "yes"
3268+
then
3269+
AC_DEFINE([MI_TSAN], [1],
3270+
[Define MI_TSAN for thread sanitizer])
3271+
fi
3272+
32673273
# Set info about shared libraries.
32683274
AC_SUBST([SHLIB_SUFFIX])
32693275
AC_SUBST([LDSHARED])

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,9 @@
15881588
<sysmacros.h>. */
15891589
#undef MAJOR_IN_SYSMACROS
15901590

1591+
/* Define MI_TSAN for thread sanitizer */
1592+
#undef MI_TSAN
1593+
15911594
/* Define if mvwdelch in curses.h is an expression. */
15921595
#undef MVWDELCH_IS_EXPRESSION
15931596

0 commit comments

Comments
 (0)