-
Notifications
You must be signed in to change notification settings - Fork 11
Description
In Python3.11+, it seems that Cothread is incompatible with Coverage. Attempting to run it will cause a segmentation fault during Pytest's cleanup stage, presumably at the stage when Coverage is doing its processing.
To recreate, create a Python3.11 virtual environment and add this program to the tests/ directory, named test_crash.py or simiar.
import cothread
def tick():
print("Test tick print!")
def tock():
print("Test tock print!")
def test_stuff():
t = cothread.Timer(0.1, tick)
cothread.Spawn(tock).Wait()
if __name__ == "__main__":
test_stuff()
Then run pytest -s --cov=cothread --cov-report term --cov-report xml:cov.xml tests/test_crash.py. You will see something similar to this:
$ pytest -s --cov=cothread --cov-rep
ort term --cov-report xml:cov.xml tests/test_crash.py
======================== test session starts ========================
platform linux -- Python 3.12.8, pytest-8.3.5, pluggy-1.5.0 -- /scratch/eyh46967/dev/cothread/venv/bin/python3.12
cachedir: .pytest_cache
rootdir: /scratch/eyh46967/dev/cothread
configfile: pyproject.toml
plugins: cov-6.1.1, anyio-4.9.0
collected 1 item
tests/test_crash.py::test_stuff Test tock print!
PASSEDFatal Python error: Segmentation fault
Thread 0x00007fbf91d02740 (most recent call first):
<no Python frame>
Thread 0x00007fbf91d02740 (most recent call first):
File Segmentation fault (core dumped)
A small amount of extra information can be gleaned from running the test under Valgrind: valgrind pytest -s --cov=cothread --cov-report term --cov-report xml:cov.xml tests/test_crash.py. See attached file.
At this time it is unknown if this is the only incompatibility with Cothread; it is possible other programs that do similar interactions with the various PyThread_* API calls will also suffer from issues or not.