Skip to content

Commit da268d4

Browse files
authored
CI: use free-threaded build for ASAN tests (numpy#28391)
While working on numpygh-28390 today, I realized that ASAN can detect issues in the free-threaded build that are impossible to hit on the GIL-enabled build. In that PR the test I added showed failures under ASAN using free-threaded Python if I ran it against a version of NumPy from last week that was susceptible to memory corruption by running the test. On the GIL-enabled build, the GIL prevents the memory corruption. For that reason, I think we can get more bang for our buck using a free-threaded interpreter to run the ASAN tests. I think the free-threaded build will catch almost all issues that the GIL-enabled build would catch as well as any problems that address sanitizer can check that are caused by race conditions. The only things we'd miss are from code in the #else block of an #if Py_GIL_DISABLED macro, and we don't really have any nontrivial code like that. I also thought about using a build matrix with both the GIL-enabled and free-threaded interpreters but given what I said above, I think just one ASAN build is fine.
1 parent 9e557eb commit da268d4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.github/workflows/compiler_sanitizers.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ jobs:
5353
echo CPPFLAGS="-I$LLVM_PREFIX/include" >> $GITHUB_ENV
5454
- name: Build Python with address sanitizer
5555
run: |
56-
CONFIGURE_OPTS="--with-address-sanitizer" pyenv install 3.13
57-
pyenv global 3.13
56+
CONFIGURE_OPTS="--with-address-sanitizer" pyenv install 3.13t
57+
pyenv global 3.13t
5858
- name: Install dependencies
5959
run: |
60+
# TODO: remove when a released cython supports free-threaded python
61+
pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython
6062
pip install -r requirements/build_requirements.txt
6163
pip install -r requirements/ci_requirements.txt
6264
pip install -r requirements/test_requirements.txt

0 commit comments

Comments
 (0)