Skip to content

Commit d8ec59e

Browse files
committed
Fix test_capi and test_cmd_line regressions on parallel-gc-dev
Two parallel-GC-related test failures, both PR-blockers for upstream: 1. test_capi: test_barrier_capacity_zero auto-discovery aborts the test_capi runner. _PyGCBarrier_Init asserts capacity > 0 and aborts the process; the test helper exists to trigger that assertion in a SUBPROCESS via test_gc_ws_deque.py. test_capi's auto-discovery of test_* functions in _testinternalcapi called it in-process and crashed the runner. Fix: rename test_barrier_capacity_zero -> unsafe_barrier_capacity_zero in Modules/_testinternalcapi/test_ws_deque.c and the corresponding subprocess invocation in Lib/test/test_gc_ws_deque.py. This is the 3.15 equivalent of commit d049fc8 on parallel_gc_backport (which fixed the same bug in the 3.12-backport tree). Cherry-pick was not possible because file structure differs: 3.12 has a single _testinternalcapi.c, 3.15 has Modules/_testinternalcapi/test_ws_deque.c. Applied as equivalent manual edit. 2. test_cmd_line: test_help_env and test_help_xoptions fail because the parallel GC additions to Python/initconfig.c (PYTHONPARALLELGC env var and -X parallel_gc option) were inserted at the wrong alphabetical position. The tests verify that env vars and X options appear in sort-order (underscore-stripped, lowercased). Fix: move PYTHONPARALLELGC to between PYTHONOPTIMIZE and PYTHON_PERF_JIT_SUPPORT. Move -X parallel_gc to between -X no_debug_ranges and -X pathconfig_warnings. Verification: - test_capi: 1356 tests pass (was: aborted) - test_cmd_line: 76 tests pass (was: 2 failed) - Full GIL test suite: 481 OK, 0 failures (was: 477 OK, 2 failed) Part of 29-05-2026 3.15 consolidation. See: ~/claude_docs/29-05-2026-parallel-gc-3.15-consolidation-plan.md ~/claude_docs/parallel_gc_pr/29-05-2026-parallel-gc-3.15-consolidation-progress.md
1 parent f688b70 commit d8ec59e

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

Lib/test/test_gc_ws_deque.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_capacity_zero(self):
102102
Falsifiability: removing assert(capacity > 0) from _PyGCBarrier_Init
103103
causes this test to hang (Wait decrements num_left=0 to UINT_MAX).
104104
"""
105-
code = "import _testinternalcapi; _testinternalcapi.test_barrier_capacity_zero()"
105+
code = "import _testinternalcapi; _testinternalcapi.unsafe_barrier_capacity_zero()"
106106
result = subprocess.run(
107107
[sys.executable, "-c", code],
108108
capture_output=True, timeout=5

Modules/_testinternalcapi/test_ws_deque.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,12 @@ test_ws_deque_concurrent_push_steal(PyObject *self, PyObject *Py_UNUSED(ignored)
526526
// ============================================================================
527527

528528
// T3-F1: Init with capacity=0 should trigger assertion
529+
//
530+
// NOTE: Named with unsafe_ prefix to prevent test_capi auto-discovery.
531+
// This function triggers assert(capacity > 0) and aborts the process.
532+
// Only called from test_gc_ws_deque.py via subprocess.
529533
static PyObject *
530-
test_barrier_capacity_zero(PyObject *self, PyObject *Py_UNUSED(ignored))
534+
unsafe_barrier_capacity_zero(PyObject *self, PyObject *Py_UNUSED(ignored))
531535
{
532536
_PyGCBarrier barrier;
533537
// This should trigger assert(capacity > 0) and abort
@@ -1328,7 +1332,7 @@ static PyMethodDef test_methods[] = {
13281332
{"test_ws_deque_concurrent_push_steal", test_ws_deque_concurrent_push_steal, METH_NOARGS, NULL},
13291333

13301334
// Barrier tests (T3-F1, T3-F9)
1331-
{"test_barrier_capacity_zero", test_barrier_capacity_zero, METH_NOARGS, NULL},
1335+
{"unsafe_barrier_capacity_zero", unsafe_barrier_capacity_zero, METH_NOARGS, NULL},
13321336
{"test_barrier_basic", test_barrier_basic, METH_NOARGS, NULL},
13331337
{"test_barrier_multiple_rounds", test_barrier_multiple_rounds, METH_NOARGS, NULL},
13341338
{"test_barrier_epoch_distinguishes", test_barrier_epoch_distinguishes, METH_NOARGS, NULL},

Python/initconfig.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,6 @@ The following implementation-specific options are available:\n\
325325
#ifdef Py_GIL_DISABLED
326326
"-X gil=[0|1]: enable (1) or disable (0) the GIL; also PYTHON_GIL\n"
327327
#endif
328-
#if defined(Py_PARALLEL_GC) || defined(Py_GIL_DISABLED)
329-
"-X parallel_gc=N: enable parallel GC with N workers;\n\
330-
also PYTHONPARALLELGC\n"
331-
#endif
332328
"\
333329
-X importtime[=2]: show how long each import takes; use -X importtime=2 to\n\
334330
log imports of already-loaded modules; also PYTHONPROFILEIMPORTTIME\n\
@@ -338,6 +334,12 @@ The following implementation-specific options are available:\n\
338334
default is normal; also PYTHON_LAZY_IMPORTS\n\
339335
-X no_debug_ranges: don't include extra location information in code objects;\n\
340336
also PYTHONNODEBUGRANGES\n\
337+
"
338+
#if defined(Py_PARALLEL_GC) || defined(Py_GIL_DISABLED)
339+
"-X parallel_gc=N: enable parallel GC with N workers;\n\
340+
also PYTHONPARALLELGC\n"
341+
#endif
342+
"\
341343
-X pathconfig_warnings=[0|1]: if true (1) then path configuration is allowed\n\
342344
to log warnings into stderr; if false (0) suppress these warnings;\n\
343345
set to true by default; also PYTHON_PATHCONFIG_WARNINGS\n\
@@ -434,9 +436,6 @@ static const char usage_envvars[] =
434436
#ifdef Py_GIL_DISABLED
435437
"PYTHON_GIL : when set to 0, disables the GIL (-X gil)\n"
436438
#endif
437-
#if defined(Py_PARALLEL_GC) || defined(Py_GIL_DISABLED)
438-
"PYTHONPARALLELGC: enable parallel GC with N workers (-X parallel_gc=N)\n"
439-
#endif
440439
"PYTHONINSPECT : inspect interactively after running script (-i)\n"
441440
"PYTHONINTMAXSTRDIGITS: limit the size of int<->str conversions;\n"
442441
" 0 disables the limit (-X int_max_str_digits=N)\n"
@@ -445,6 +444,9 @@ static const char usage_envvars[] =
445444
" (-X no_debug_ranges)\n"
446445
"PYTHONNOUSERSITE: disable user site directory (-s)\n"
447446
"PYTHONOPTIMIZE : enable level 1 optimizations (-O)\n"
447+
#if defined(Py_PARALLEL_GC) || defined(Py_GIL_DISABLED)
448+
"PYTHONPARALLELGC: enable parallel GC with N workers (-X parallel_gc=N)\n"
449+
#endif
448450
"PYTHON_PERF_JIT_SUPPORT: enable Linux \"perf\" profiler support with JIT\n"
449451
" (-X perf_jit)\n"
450452
"PYTHONPERFSUPPORT: support the Linux \"perf\" profiler (-X perf)\n"

0 commit comments

Comments
 (0)