Closed
CANN开发者共建计划--runtime python/pyACL/util/thread.cpp 中 ThrFunc 获取 GIL 后在 userData 为空时直接返回导致 GIL 永久泄漏 #1481
mellow986Add on 5 days agoClosed at 2 days ago
CANN-robot
5 days ago Comments:
5 days ago Comments:
提交内容规范性检查:未通过
原因:未匹配现有模板
Issue 报告 pyACL 线程入口 ThrFunc 在 userData 为空时早退未调用 PyGILState_Release,导致 GIL 永久泄漏和进程死锁,属于已有代码功能异常的缺陷反馈。正文已按问题描述、环境信息、复现步骤、当前与预期结果组织,与缺陷反馈模板字段一一对应,可补充日志或截图后直接套用。
模板推荐:Bug-Report|缺陷反馈
展开显示模板内容,将模板内容复制到 Issue 中填写。
模板标题
[Bug-Report|缺陷反馈]:
模板正文(Markdown)
### Describe the current behavior / 问题描述 (Mandatory / 必填)
<!-- 必填
提供尽可能多的信息描述产生了什么问题 -->
### Environment / 环境信息 (Mandatory / 必填)
<!-- 必填
请提供昇腾硬件型号与软件环境信息 -->
### Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)
<!-- 必填
提供尽可能多的信息描述如何重现该缺陷 -->
### Describe the expected behavior / 预期结果 (Mandatory / 必填)
<!-- 必填
描述期望的行为应该是什么样子的 -->
### Related log / screenshot / 日志 / 截图 (Mandatory / 必填)
<!-- 必填
提供尽可能多的日志/结果信息 -->
### Special notes for this issue/备注 (Optional / 选填)
<!-- 选填
补充下其他您认为需要提供的信息 -->


wuqifan
5 days ago Comments:
5 days ago Comments:
/assign


5 days ago Assign weixin_46600764 as responsible person
wuqifan
5 days ago Comments:
5 days ago Comments:
你好。初步核对确认,ThrFunc 获取 GIL 后遇到空 userData 会直接返回,缺少配对的 PyGILState_Release。报告基线和当前 master 均存在该路径。常规 acl.util.start_thread 调用会先检查线程控制块分配结果。实测传入 Python None 时,无参回调正常执行,stop_thread 返回 0。我们会进一步验证复现该问题,如已有修复 MR,可以补充链接,感谢你的反馈!


2 days ago Associated pull request
2 days ago Associated pull request
ykl999
2 days ago Comments:
2 days ago Comments:
你好,问题pr已合入,详见https://gitcode.com/cann/runtime/pull/6580
感谢指出问题!


2 days ago changed custom state from 待办的 to 已解决
2 days ago Close issue
1、描述
我在检查 pyACL 线程封装
python/pyACL/util/thread.cpp时,发现线程入口函数ThrFunc(void* userData)第 64 行先调用PyGILState_STATE state = PyGILState_Ensure();抢占 GIL,随后在第 67~70 行校验if (userData == nullptr)失败时直接return nullptr;结束线程,漏掉了PyGILState_Release(state)。一旦线程携带空指针启动,子线程退出后 GIL 永远处于被锁定状态,直接造成整个 Python 进程死锁。2、环境信息
master(8f16f26)3、复现步骤 / 操作步骤
userData;ThrFunc获取 GIL 后在userData == nullptr分支直接退出;4、当前结果
子线程持有 GIL 退出,Python 进程内所有线程无法再次获得 GIL 而发生死锁。
5、预期结果
在
userData == nullptr早退返回前调用PyGILState_Release(state)释放 GIL。