python / python/cpython

sys.setprofile and equivalent C API don't track all callable C code

未關閉
#126,056 6 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

type-feature
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:
import sys
import mmap

def prof(frame, event, arg):
    print(event, arg)

sys.setprofile(prof)

x = mmap.mmap(-1, 10_000)
open("/dev/null")

When run with Python 3.13 on Linux:

c_call <built-in function open>
call None
call None
return None
return None
c_return <built-in function open>
return None

No mention of mmap.mmap(), perhaps because it's a constructor of a type object.

(This is really an issue with the underlying C API, PyTrace_C_CALL is similarly not happening.)

As someone doing profiling, this means that any code running inside C type constructors is invisible, which is problematic and means I'm going to have to change how one of my profilers works.

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用 sys.setprofile、mmap.mmap() 和 open() 重現 Linux 範例,然後追蹤 PyTrace_C_CALL 與 C 類型建構函式周圍的 profiling 路徑。將觀察到的事件與可呼叫 C 程式碼的預期可見性進行比較;當相關的建構函式活動透過 sys.setprofile 和等效的 C API 一致地回報時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
c, python
領域
devtools
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。