`tracemalloc` aborts when run from threads in no-gil
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?
It's possible to get two different aborts from failed assertions, only with PYTHON_GIL=0, using the code below:
from threading import Thread
import _tracemalloc
alive = [
Thread(target=_tracemalloc.start, args=(
(memoryview(bytearray(b"abc\xe9\xff")),))),
Thread(target=_tracemalloc.start, args=()),
Thread(target=_tracemalloc.get_traceback_limit, args=()),
Thread(target=_tracemalloc.start, args=()),
Thread(target=_tracemalloc.stop, args=()),
Thread(target=_tracemalloc.reset_peak, args=()),
Thread(target=_tracemalloc.get_tracemalloc_memory, args=())
]
for obj in alive:
print('START', obj)
try:
obj.start()
except Exception:
pass
The errors are:
python: Python/tracemalloc.c:445: tracemalloc_remove_trace: Assertion `tracemalloc_config.tracing' failed.
Aborted
And:
python: Python/tracemalloc.c:469: tracemalloc_add_trace: Assertion `tracemalloc_config.tracing' failed.
Aborted
Found with fusil by @vstinner.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a1+ experimental free-threading build (heads/main:d467d9246c, Nov 1 2024, 09:05:56) [GCC 11.4.0]
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
Bắt đầu bằng cách tái hiện ví dụ đa luồng được cung cấp bằng một bản build free-threading thử nghiệm và PYTHON_GIL=0. Kiểm tra Python/tracemalloc.c xung quanh tracemalloc_remove_trace và tracemalloc_add_trace, sau đó xác minh rằng ví dụ không còn bị abort khi các thao tác tracemalloc được sử dụng đồng thời.
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
- devtools
- 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
- 45/100