`arraymodule`, `_decimal`: possible lazy import caches reference leaks in free-threaded builds
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ả
Bug description:
As pointed out by @htjworld in https://github.com/python/cpython/pull/148088#issuecomment-4196296604:
I was wondering about the lazy init pattern in a free-threaded build. If two threads enter
build_struct_timeconcurrently withst->time_struct_time == NULL, both would callPyImport_ImportModuleAttrStringand one overwrite would leave a reference with an incremented refcount that never gets decref'd.
I noticed
arraymodule.cand_decimal.chave the same pattern, so maybe this is just accepted. But _asynciomodule.c initializes eagerly in module_init() which avoids this structurally. Was lazy chosen deliberately here over eager init in init_state()?
While I've addressed this in #148088, I think that this is a valid concern, and import caches should use CAS, just like:
If there's interest, I can do it.
(It seems similar to #149000, so perhaps a more thorough check warranted.)
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
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 so sánh việc khởi tạo lazy trong arraymodule.c và _decimal.c với việc khởi tạo eager trong _asynciomodule.c và mẫu CAS trong Modules/_sre/sre.c. Kiểm tra các đường dẫn free-threaded để phát hiện việc khởi tạo đồng thời và rò rỉ tham chiếu; công việc được xem là hoàn tất khi các import cache bị ảnh hưởng an toàn với mẫu đồng thời này và hành vi liên quan được bao phủ bởi việc validation.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, python
- Lĩnh vực
- backend
- 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
- 48/100