dtrace: debug abort importing module with lone surrogate unicode char in name while DTrace import probe is active
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
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)]
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Build Python với --with-dtrace và tái hiện assertion bằng các ví dụ probe.d và test.py. Kiểm tra các import hook trong Python/import.c và mã DTrace bổ sung trong Python/ceval.c, bao gồm cả các vị trí được liên kết. Được xem là hoàn tất khi việc import một lone-surrogate không còn để lại stale exception hoặc kích hoạt debug assertion trong khi probe đang hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- observability
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 50/100