# worker 'gw3' crashed while running 'tests/test_heavy.py::test_parallel'
[gw3] node down: Not properly terminated
Replacing crashed worker gw3

- **ID:** `python/pytest-xdist-worker-crash-fork`
- **Domain:** python
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A test uses fork() or multiprocessing with the fork start method inside an xdist worker; forking a process that already has threads (xdist workers do) leads to deadlocks or SIGSEGV.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.6.x | active | — | — |
| 3.7.x | active | — | — |

## Workarounds

1. **** (93% success)
   ```
   import multiprocessing as mp

if __name__ == '__main__':
    mp.set_start_method('spawn', force=True)

# In test fixture:
ctx = mp.get_context('spawn')
with ctx.Pool(2) as p:
    ...
   ```
2. **** (88% success)
   ```
   # In conftest.py
def pytest_collection_modifyitems(items):
    for it in items:
        if 'heavy' in it.keywords:
            it.add_marker(pytest.mark.xdist_group('serial'))

# Run:
pytest -n auto --dist loadgroup
   ```

## Dead Ends

- **** — Masks the crash and slows the suite; the underlying fork-in-threaded-process bug still occurs on every run. (80% fail)
- **** — Defeats parallelism entirely; on large suites CI time can triple and the test that triggered the crash still runs unsafely. (70% fail)
