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 摘要。