@@ -166,7 +166,13 @@ def _run_in_threads(target, num_threads, parallel):
166
166
thread .join ()
167
167
168
168
169
+ # m.defined_THREAD_SANITIZER is used below to skip tests triggering this error (#2754):
170
+ # ThreadSanitizer: starting new threads after multi-threaded fork is not supported.
171
+
169
172
# TODO: FIXME, sometimes returns -11 (segfault) instead of 0 on macOS Python 3.9
173
+ @pytest .mark .skipif (
174
+ m .defined_THREAD_SANITIZER , reason = "Not compatible with ThreadSanitizer"
175
+ )
170
176
@pytest .mark .parametrize ("test_fn" , ALL_BASIC_TESTS )
171
177
def test_run_in_process_one_thread (test_fn ):
172
178
"""Makes sure there is no GIL deadlock when running in a thread.
@@ -177,6 +183,9 @@ def test_run_in_process_one_thread(test_fn):
177
183
178
184
179
185
# TODO: FIXME on macOS Python 3.9
186
+ @pytest .mark .skipif (
187
+ m .defined_THREAD_SANITIZER , reason = "Not compatible with ThreadSanitizer"
188
+ )
180
189
@pytest .mark .parametrize ("test_fn" , ALL_BASIC_TESTS )
181
190
def test_run_in_process_multiple_threads_parallel (test_fn ):
182
191
"""Makes sure there is no GIL deadlock when running in a thread multiple times in parallel.
@@ -190,6 +199,9 @@ def test_run_in_process_multiple_threads_parallel(test_fn):
190
199
191
200
192
201
# TODO: FIXME on macOS Python 3.9
202
+ @pytest .mark .skipif (
203
+ m .defined_THREAD_SANITIZER , reason = "Not compatible with ThreadSanitizer"
204
+ )
193
205
@pytest .mark .parametrize ("test_fn" , ALL_BASIC_TESTS )
194
206
def test_run_in_process_multiple_threads_sequential (test_fn ):
195
207
"""Makes sure there is no GIL deadlock when running in a thread multiple times sequentially.
@@ -206,6 +218,14 @@ def test_run_in_process_direct(test_fn):
206
218
207
219
This test is for completion, but it was never an issue.
208
220
"""
221
+ if m .defined_THREAD_SANITIZER and test_fn in (
222
+ test_cross_module_gil_nested_custom_released ,
223
+ test_cross_module_gil_nested_custom_acquired ,
224
+ test_cross_module_gil_nested_pybind11_released ,
225
+ test_cross_module_gil_nested_pybind11_acquired ,
226
+ test_multi_acquire_release_cross_module ,
227
+ ):
228
+ pytest .skip ("Not compatible with ThreadSanitizer" )
209
229
exitcode = _run_in_process (test_fn )
210
230
if exitcode is None and env .PYPY and env .WIN : # Seems to be flaky.
211
231
pytest .skip ("Ignoring unexpected exitcode None (PYPY WIN)" )
0 commit comments