Cothread generates segmentation faults when run with Coverage
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- backend, testing-qa
Research direction
Start by reproducing the crash with tests/test_crash.py using the documented pytest and coverage command under Python 3.11 or newer. Then inspect Cothread's PyThread_* API interactions and compare the failure with the attached Valgrind output. Done means the reproduction completes under coverage without a segmentation fault and related thread interactions are checked for regressions.
Written by the indexing model from the issue text.
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.
- Dominant language
- C
- Stars
- 13
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DiamondLightSource/cothread
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DiamondLightSource/cothread#78 · 2 comments ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DiamondLightSource/cothread#75 · 5 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
DiamondLightSource/cothread#68 · 3 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
DiamondLightSource/cothread#67 · 2 comments ·
All issues in DiamondLightSource/cothread
Similar issues
-
level/task module/gcp type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
P3 sonic-vpp
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sonic-net/sonic-buildimage#29662 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
spack/spack-packages#6586 ·