Skip to content

Commit 304fde4

Browse files
hipvladyclaude
andcommitted
Fix CI/CD segmentation fault by disabling parallel test execution
🔧 **CRITICAL FIX**: Disable pytest-xdist to prevent segfaults ## Problem - CI pipeline experiencing segmentation faults at ~2 hours - Caused by nested multiprocessing: pytest-xdist + ProcessPoolExecutor - Tests hang indefinitely, blocking all CI/CD ## Solution (Workaround) - Removed `-n auto` flag from pytest command (disable parallel execution) - All tests now run serially to ensure stability - Performance tests already isolated (run separately) ## Impact - ✅ CI pipeline completes successfully - ⚠️ Runtime increased from ~15min to ~30-40min (serial execution) - ✅ No more hangs or segfaults ## Technical Details - Attempted: multiprocessing.set_start_method("spawn") - insufficient - Working: Complete disable of pytest-xdist parallel execution - TODO: Investigate root cause and re-enable parallel execution ## Files Modified - .github/workflows/ci.yml: Removed -n auto, added workaround comments - CHANGELOG.md: Documented workaround and known issues 🚀 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 20e4764 commit 304fde4

2 files changed

Lines changed: 25 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,24 @@ jobs:
179179
180180
- name: Run comprehensive test suite with automatic discovery
181181
id: test-runner
182+
env:
183+
# Fix multiprocessing segfaults by forcing spawn method
184+
PYTEST_XDIST_WORKER_COUNT: "0"
182185
run: |
183186
echo "🚀 Running comprehensive test suite with automatic discovery..."
184187
echo ""
185188
186189
# Determine number of CPUs for parallel execution
187190
NUM_CPUS=$(python -c "import os; print(os.cpu_count())")
188191
echo "💻 Available CPUs: $NUM_CPUS"
189-
echo "🔄 Parallel workers: auto (pytest-xdist will optimize)"
192+
echo "⚠️ Running in SERIAL mode due to multiprocessing segfault"
190193
echo ""
191194
192-
# Run ALL tests in tests/ directory with enhancements:
193-
# - Parallel execution with pytest-xdist (-n auto)
194-
# - Retry failed tests up to 2 times (--reruns 2 --reruns-delay 1)
195-
# - Timeout for hanging tests (--timeout 300 = 5 minutes per test)
196-
# - Exclude performance benchmarks from regular runs
195+
# TEMPORARY FIX: Run without -n auto to avoid segfault
196+
# The multiprocessing code conflicts with pytest-xdist
197+
# TODO: Re-enable parallel execution after fixing multiprocessing issues
197198
python -m pytest tests/ \
198199
--ignore=tests/performance/ \
199-
-n auto \
200200
--reruns 2 \
201201
--reruns-delay 1 \
202202
--timeout=300 \
@@ -214,7 +214,7 @@ jobs:
214214
if [ "${TEST_EXIT_CODE:-0}" -eq 0 ]; then
215215
echo ""
216216
echo "✅ All tests passed!"
217-
echo "🚀 Performance: Parallel execution with $NUM_CPUS CPUs"
217+
echo "⚙️ Mode: Serial execution (parallel disabled due to segfault)"
218218
echo "🔄 Reliability: Failed tests auto-retried up to 2 times"
219219
echo "⏱️ Safety: 5-minute timeout per test"
220220
else

CHANGELOG.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
## [1.0.2] - 2025-10-05
2222

2323
### Fixed
24-
- **CI/CD Segmentation Fault**
25-
- Fixed segmentation fault in CI pipeline caused by nested multiprocessing conflicts
26-
- Added platform-specific multiprocessing configuration (use `spawn` method on Linux)
27-
- Separated performance tests to run serially (without pytest-xdist) to avoid multiprocessing conflicts
28-
- Added `@pytest.mark.no_parallel` marker for tests using ProcessPoolExecutor
29-
- CI/CD pipeline now completes in ~20-25 minutes instead of hanging at ~2 hours
24+
- **CI/CD Segmentation Fault (Workaround)**
25+
- **CRITICAL**: Disabled pytest-xdist parallel execution to prevent segmentation faults
26+
- Root cause: Nested multiprocessing (pytest-xdist + ProcessPoolExecutor) causes segfaults on Linux
27+
- All tests now run serially to ensure pipeline stability
28+
- CI/CD pipeline completes successfully (~30-40 minutes vs hanging at ~2 hours)
3029

3130
### Changed
32-
- Performance tests now run separately from main test suite to prevent multiprocessing conflicts
33-
- Updated pytest configuration to use `spawn` multiprocessing method on Linux (CI environment)
34-
- Regular tests still run in parallel for optimal performance; only performance tests run serially
31+
- **TEMPORARY**: Disabled parallel test execution (`-n auto` removed from pytest command)
32+
- Performance tests run separately from main test suite
33+
- Added multiprocessing configuration in `tests/conftest.py` (not sufficient alone)
34+
- Added `@pytest.mark.no_parallel` marker for multiprocessing tests
35+
36+
### Known Issues
37+
- Tests run serially, increasing CI time from ~15 min to ~30-40 min
38+
- Need to investigate root cause of multiprocessing conflicts
39+
- Future fix should re-enable parallel execution after resolving conflicts
3540

3641
### Technical Details
37-
- Root cause: pytest-xdist worker processes + ProcessPoolExecutor created nested multiprocessing
38-
- Solution: Force `spawn()` instead of `fork()` on Linux + isolate multiprocessing tests
42+
- Root cause: pytest-xdist worker processes + ProcessPoolExecutor create nested multiprocessing
43+
- Attempted fix: `multiprocessing.set_start_method("spawn")` in pytest_configure (insufficient)
44+
- Working solution: Disable pytest-xdist entirely until multiprocessing conflicts resolved
3945
- Files modified: `tests/conftest.py`, `.github/workflows/ci.yml`, `tests/performance/test_cpu_bound_multiprocessing.py`
4046

4147
## [1.0.1] - 2025-10-05

0 commit comments

Comments
 (0)