python / python/cpython

Various UB warnings found by UBSan

未关闭
#148,286 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

extension-modules interpreter-core type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:

These were all found by UBSan in our CI (it just hasn't been complaining about them). They need to be individually checked, some may be false positives.

# Objects/object.c:97:5: runtime error: member access within null pointer of type 'PyThreadState' (aka 'struct _ts')
null:Objects/object.c

In test_memoryview:

# Objects/memoryobject.c:3032:15: runtime error: load of value 2, which is not a valid value for type 'bool'
bool:Objects/memoryobject.c

In test_ctypes:

# Modules/_ctypes/cfield.c:644:1: runtime error: left shift of 1 by 63 places cannot be represented in type 'int64_t' (aka 'long')
shift-base:Modules/_ctypes/cfield.c

# Modules/_ctypes/cfield.c:640:1: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
signed-integer-overflow:Modules/_ctypes/cfield.c

In test_zstd:

# Modules/_zstd/decompressor.c:598:56: runtime error: applying non-zero offset 18446744073709551615 to null pointer
pointer-overflow:Modules/_zstd/decompressor.c
# Modules/_io/stringio.c:350:24: runtime error: addition of unsigned offset to 0x7fd01ec25850 overflowed to 0x7fd01ec2584c
pointer-overflow:Modules/_io/stringio.c
# Objects/bytesobject.c:1190:25: runtime error: applying zero offset to null pointer
pointer-overflow:Objects/bytesobject.c
CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-151274
  • gh-148168
  • gh-153187
  • gh-153204
  • gh-153258
  • gh-153644
  • gh-153645
  • gh-154912
  • gh-154913
  • gh-154915
  • gh-154926

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先检查 UBSan 报告以及 Objects/object.c、Objects/memoryobject.c、Modules/_ctypes/cfield.c、Modules/_zstd/decompressor.c、Modules/_io/stringio.c 和 Objects/bytesobject.c 中提到的位置。运行相关的 UBSan CI 测试,然后确定哪些警告是有效的,哪些是误报,并验证每个警告都已得到处理。已链接的 PR 表明相关工作已经在进行中。

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

评估

技术栈
c
领域
testing-qa
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
15/100

把新 issue 发到你的邮箱

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