dtrace: debug abort importing module with lone surrogate unicode char in name while DTrace import probe is active
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Crash report
What happened?
This one is a bit niche! It also needs a python compiled with --with-dtrace
probe.d:
python$target:::import-find-load-start
{
printf("import probe fired\n");
}
test.py:
try:
__import__('\ud800')
except:
pass
> sudo dtrace -q -s probe.d -c './python.exe test.py'
Assertion failed: (!_PyErr_Occurred(tstate)), function _PyEval_EvalFrameDefault, file generated_cases.c.h, line 13858.
import probe fired
import probe fired
import probe fired
...
The import dtrace hooks pass call PyUnicode_AsUTF8 and pass the value to the probe without checking if the conversion succeeded, now dtrace doesn't seem to mind getting a null pointer (I don't know much about how that bit works tbh), but a stale exception is left around which triggers a debug assert:
[!CAUTION]
EDIT: I found some more cases of drace code doing the same, This isn't just limited to import machinery:
https://github.com/python/cpython/blob/91d71dd67074d4599b6bd49cc933f41f8bd57058/Python/ceval.c#L1198-L1225
If I find more, I'll add them
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Output from running 'python -VV' on the command line:
Python 3.16.0a0 (heads/main:e8158d1a02d, Aug 20 2026, 15:09:24) [Clang 21.0.0 (clang-2100.3.27.1)]
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
--with-dtrace を指定して Python をビルドし、probe.d と test.py の例を使って assertion を再現します。Python/import.c の import hook と、リンクされている箇所を含む Python/ceval.c の追加の DTrace コードを調査します。probe がアクティブな間に lone-surrogate の import が stale exception を残さず、debug assertion もトリガーしなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- observability
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 50/100