Skip to content

Commit f568688

Browse files
Move ASan CI job to reusable-san.yml
This refactors the CI configuration for ASan to deduplicate some logic, and bring it together with the other sanitzers. As a sideeffect, it will also run `--with-pydebug` and build with the Clang compiler.
1 parent e29cce5 commit f568688

2 files changed

Lines changed: 29 additions & 57 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -481,53 +481,6 @@ jobs:
481481
if: fromJSON(needs.build-context.outputs.run-tests)
482482
uses: ./.github/workflows/reusable-test-lazy-imports-all.yml
483483

484-
build-asan:
485-
name: 'Address sanitizer'
486-
runs-on: ${{ matrix.os }}
487-
timeout-minutes: 60
488-
needs: build-context
489-
if: needs.build-context.outputs.run-ubuntu == 'true'
490-
strategy:
491-
fail-fast: false
492-
matrix:
493-
os: [ubuntu-26.04]
494-
env:
495-
OPENSSL_VER: 3.5.9
496-
PYTHONSTRICTEXTENSIONBUILD: 1
497-
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
498-
steps:
499-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
500-
with:
501-
persist-credentials: false
502-
- name: Runner image version
503-
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
504-
- name: Register gcc problem matcher
505-
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
506-
- name: Install dependencies
507-
run: sudo ./.github/workflows/posix-deps-apt.sh
508-
- name: Configure OpenSSL env vars
509-
run: |
510-
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
511-
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV"
512-
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> "$GITHUB_ENV"
513-
- name: 'Restore OpenSSL build'
514-
id: cache-openssl
515-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
516-
with:
517-
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
518-
key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
519-
- name: Install OpenSSL
520-
if: steps.cache-openssl.outputs.cache-hit != 'true'
521-
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux
522-
- name: Configure CPython
523-
run: ./configure --config-cache --with-address-sanitizer --without-pymalloc --with-openssl="$OPENSSL_DIR"
524-
- name: Build CPython
525-
run: make -j4
526-
- name: Display build info
527-
run: make pythoninfo
528-
- name: Tests
529-
run: xvfb-run make ci
530-
531484
build-san:
532485
# ${{ '' } is a hack to nest jobs under the same sidebar category.
533486
name: Sanitizers${{ '' }} # zizmor: ignore[obfuscation]
@@ -544,6 +497,9 @@ jobs:
544497
sanitizer:
545498
- TSan
546499
include:
500+
- check-name: Address
501+
sanitizer: ASan
502+
free-threading: false
547503
- check-name: Undefined behavior
548504
sanitizer: UBSan
549505
free-threading: false
@@ -657,7 +613,6 @@ jobs:
657613
- build-wasi
658614
- test-hypothesis
659615
- test-lazy-imports-all
660-
- build-asan
661616
- build-san
662617
- cross-build-linux
663618
- cifuzz
@@ -704,7 +659,6 @@ jobs:
704659
build-ubuntu-installed,
705660
build-ubuntu-ssltests,
706661
test-hypothesis,
707-
build-asan,
708662
build-san,
709663
cross-build-linux,
710664
'

‎.github/workflows/reusable-san.yml‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ jobs:
4343
# please update the versions in `Tools/pixi-packages/variants.yaml` too.
4444
echo "CC=clang" >> "$GITHUB_ENV"
4545
echo "CXX=clang++" >> "$GITHUB_ENV"
46+
- name: ASan option setup
47+
if: inputs.sanitizer == 'ASan'
48+
run: |
49+
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
50+
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> "$GITHUB_ENV"
51+
echo "ASAN_OPTIONS=${SAN_LOG_OPTION} detect_leaks=0 allocator_may_return_null=1 handle_segv=0" >> "$GITHUB_ENV"
52+
echo "PYTHONSTRICTEXTENSIONBUILD=1" >> "$GITHUB_ENV"
53+
env:
54+
SAN_LOG_OPTION: log_path=${{ github.workspace }}/san_log
4655
- name: TSan option setup
4756
if: inputs.sanitizer == 'TSan'
4857
run: |
@@ -88,24 +97,27 @@ jobs:
8897
- name: Add ccache to PATH
8998
run: |
9099
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
91-
- name: 'Restore OpenSSL build (TSan)'
100+
- name: 'Restore OpenSSL build'
92101
id: cache-openssl
93-
if: inputs.sanitizer == 'TSan'
102+
if: inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan'
94103
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
95104
with:
96105
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
97-
key: ${{ env.IMAGE_OS_VERSION }}-multissl-openssl-tsan-${{ env.OPENSSL_VER }}
98-
- name: Install OpenSSL (TSan)
106+
key: >-
107+
${{ env.IMAGE_OS_VERSION }}-multissl-openssl-${{
108+
inputs.sanitizer == 'TSan' && 'tsan-' || ''
109+
}}${{ env.OPENSSL_VER }}
110+
- name: Install OpenSSL
99111
if: >-
100-
inputs.sanitizer == 'TSan'
112+
(inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan')
101113
&& steps.cache-openssl.outputs.cache-hit != 'true'
102114
run: >-
103115
python3 Tools/ssl/multissltests.py
104116
--steps=library
105117
--base-directory="${MULTISSL_DIR}"
106118
--openssl="${OPENSSL_VER}"
107119
--system=Linux
108-
--tsan
120+
${{ inputs.sanitizer == 'TSan' && '--tsan' || '' }}
109121
# gh-157958: -O2 instead of the pydebug default -Og to avoid a clang 21
110122
# compile-time blowup on some interpreter files.
111123
# (https://github.com/llvm/llvm-project/issues/179695)
@@ -117,14 +129,20 @@ jobs:
117129
--config-cache
118130
OPT="-O2 -g"
119131
${{
120-
inputs.sanitizer == 'TSan'
132+
inputs.sanitizer == 'ASan'
133+
&& '--with-address-sanitizer --without-pymalloc'
134+
|| inputs.sanitizer == 'TSan'
121135
&& '--with-thread-sanitizer'
122136
|| inputs.sanitizer == 'MSan'
123137
&& '--with-memory-sanitizer'
124138
|| '--with-undefined-behavior-sanitizer --with-strict-overflow'
125139
}}
126140
${{ inputs.sanitizer == 'MSan' && '--with-assertions' || '--with-pydebug' }}
127-
${{ inputs.sanitizer == 'TSan' && '--with-openssl="$OPENSSL_DIR" --with-openssl-rpath=auto' || '' }}
141+
${{
142+
(inputs.sanitizer == 'TSan' || inputs.sanitizer == 'ASan')
143+
&& '--with-openssl="$OPENSSL_DIR" --with-openssl-rpath=auto'
144+
|| ''
145+
}}
128146
${{ inputs.free-threading && '--disable-gil' || '' }}
129147
- name: Build CPython
130148
run: make -j4

0 commit comments

Comments
 (0)