Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Cothread generates segmentation faults when run with Coverage

未关闭
#73 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c, python

调研方向

首先,在 Python 3.11 或更高版本下,使用文档中说明的 pytest 和 coverage 命令,通过 tests/test_crash.py 重现崩溃。然后检查 Cothread 的 PyThread_* API 交互,并将该故障与随附的 Valgrind 输出进行比较。当重现过程在 coverage 下完成且未发生 segmentation fault,并且已检查相关线程交互是否存在回归时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug

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.

valgrind_output.txt

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.

主要语言
C
星标
13
派生
11
PR 合并指标
30 天内没有已合并 PR

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DiamondLightSource/cothread 的其他 Issue

查看 DiamondLightSource/cothread 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。