Potential thread unsafety in test_free_threading.test_monitoring
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 36k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug report
Bug description:
It seems that there is some kind of race with test_free_threading.test_monitoring, specifically the sys.settrace tests:
https://github.com/python/cpython/blob/fba5dded6df3c2b1943557afef89a5cb418f65a2/Lib/test/test_free_threading/test_monitoring.py#L143-L166.
This was initially spotted in a buildbot failure here: https://buildbot.python.org/#/builders/1610/builds/1590. There have been a few behaviors noted:
- refleaks causing a test failure
- assertion failures
- presumed deadlocks or other contention causing the tests to run extremely slowly (timing out after 45 minutes)
- tests pass without issue 😬
The variety of failure modes makes me think there is some kind of thread safety issue lurking behind the failures...
After some local debugging (the remote debugger rocks!), I was able to reproduce the extremely long test run of test_freethreading, and narrow down the majority of the time being in the sys.settrace tests. My command line was:
./python -E -m test --timeout=2700 -R 3:3 -u-cpu -j10 test_free_threading
On my x86 laptop on Ubuntu 24.04/WSL.
Reading over the test, it isn't clear to me what is meant to be tested. sys.settrace only affects the current thread according to the docs (indeed, the C code sets the trace function to the current threadstate), so currently it is only checking that the main thread executes a frame of some sort.
I didn't have time to find the root cause of the weird behavior above, so I'm filing this bug to note down my findings.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
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 với các dòng 143-166 trong Lib/test/test_free_threading/test_monitoring.py và tái hiện sự cố bằng ./python -E -m test --timeout=2700 -R 3:3 -u-cpu -j10 test_free_threading. Điều tra các kiểm thử sys.settrace cùng với lỗi buildbot được liên kết và xác định nguồn gốc của race, tranh chấp hoặc rò rỉ. Được coi là hoàn thành khi đã hiểu chế độ lỗi và các kiểm thử bị ảnh hưởng chạy ổn định.
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
- testing-qa
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100