python / python/cpython

Wild pointer detected with ASAN during source build

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

还没有人认领这个 Issue。

OS-windows type-bug
主要语言
Python
星标
77.2k
派生
36k
PR 合并指标
PR 指标待抓取

描述

Hi,

We have a regression test system based on Python in Windows OS. Recently we updated to VS 2022 and investigated using the Address Sanitizer feature - https://docs.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-170

In order for us to utilise the feature we need to python from source with the compile option /fsanitize=address enabled.
we have tried with 3.8.1 and 3.9.13 (we tried with latest 3.10.7 but encounter an issue with nuget.exe fetching python
x86 - https://stackoverflow.com/questions/73411602/unable-to-find-package-pythonx86-via-nuget)

On both 3.81 and 3.9.13 we are able to build from source python with no issue however with address sanitizer enabled we encounter the following wild pointer error :

==5104==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x02302010 at pc 0x68d65232 bp 0x00cfefbc sp 0x00cfefb0
READ of size 4 at 0x02302010 thread T0
**** CALL STACK ****
Address 0x02302010 is a wild pointer.
SUMMARY: AddressSanitizer: heap-buffer-overflow C:\Users\livuser\Downloads\Python-3.9.13\Python-3.9.13_pre\Objects\obmalloc.c:1420 in address_in_range
Shadow bytes around the buggy address:
**** VISUAL OF BUGGY MEMORY ****

Full output of build.bat is attached as output.log

To set up it is a little tedious as each project file (.vcproj) used in the pcbuild solution requires the following lines adding since we don't have easy access to the compile commands through the bat file

VCPROJ addition (had to remove < these braces > due to text editor hiding entries):
PropertyGroup
EnableASAN true /EnableASAN
/PropertyGroup

Has Python been built with the address sanitizer tool enabled? In Linux it is easy as we can just apply LD_PRELOAD to provide the address sanitizer as a shared library but this is less trivial in Windows OS which is our primary use case.

Thanks in advance for any input on this issue!
Richard


output.log

贡献指南

打开贡献指南

从这里开始

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

调研方向

先从附件中的 output.log 和 Objects/obmalloc.c 的 address_in_range(第 1420 行)开始,然后检查添加了 /fsanitize=address 的 build.bat 和 pcbuild 项目文件。使用 ASAN 重现 Windows 源代码构建,并确定报告的 allocator 访问是受支持构建的问题还是缺陷;完成的标准是确认原因并具备回归覆盖,或记录明确的限制。

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

评估

技术栈
python
领域
build-system, testing-qa
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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