heap uaf in _lsprof via enable()
未关闭
还没有人认领这个 Issue。
extension-modules
topic-profiling
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
import _lsprof
prof = _lsprof.Profiler()
def _timer():
try:
prof.enable()
except Exception:
pass
return 0
prof.__init__(timer=_timer)
prof.enable()
def foo():
return 1
foo()
prof.disable()
ASAN output (truncated:
==ERROR: AddressSanitizer: heap-use-after-free ... READ of size 8
#0 ptrace_enter_call Modules/_lsprof.c:383
#1 _lsprof_Profiler__ccall_callback_impl Modules/_lsprof.c:733
freed by thread T0 here:
#1 flush_unmatched Modules/_lsprof.c:873
#2 _lsprof_Profiler_disable_impl Modules/_lsprof.c:930
previously allocated by thread T0 here:
#1 ptrace_enter_call Modules/_lsprof.c:388
SUMMARY: AddressSanitizer: heap-use-after-free Modules/_lsprof.c:383 in ptrace_enter_call
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-157648
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
在 ASAN 下使用 Python 代码片段重现该报告,并检查 Modules/_lsprof.c,从 ptrace_enter_call 和 _lsprof_Profiler__ccall_callback_impl 路径开始。阅读 flush_unmatched 和 _lsprof_Profiler_disable_impl,以追踪分配和释放的顺序。当复现程序在启用/禁用 profiler 期间不再报告 heap-use-after-free 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, python
- 领域
- performance, tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100