Repository navigation
gh-161769: Preserve errno across release thread-state attachment - #161770
Robolightning wants to merge 5 commits into
Conversation
Keep the existing _PyThreadState_Attach errno save/restore in release builds as well as debug builds. A release free-threaded attachment can wait for GC or critical-section resumption and change errno, causing valid directory EOF and cold FileFinder operations to raise spurious EAGAIN. Add a public directory/scandir/FileFinder regression under real child-local GC, without native diagnostic modules or third-party code. The identical test fails on current main 3.16 before the four-guard-line change and passes afterwards. Original IO, GC, threading and import suites also pass on the native musl release FT source build. No installed SDK is modified.
Correct the new NEWS reference rejected by the actual Docs job. Keep the qualified native source and public regression unchanged.
Actual upstream TSanFT reached the new hard30second worker-join timeout before the scanners finished. Use test.support.LONG_TIMEOUT as recommended for slow/instrumented buildbots. Keep all scan/GC workload and assertions. Re-prove the identical adjusted test on both current3.15 andmain native release FT cores: actual BlockingIOError before, PASS after unchanged errno fix. Original failing CI log and native loaded-library hashes are retained.
|
Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate. Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors. This contribution appears to have been authored with AI assistance. Please explain your contribution in your own words and describe how you checked its correctness. Please read our guidelines for using AI tools. |
|
I can only reproduce this on musl; elsewhere the new test passes without the fix. Please explain why and make sure your changes are minimal and focused. |
Replace the directory/SI lifecycle helper with one public listdir test using the existing run_concurrently helper. Four ordinary threads each collect GC and check a real directory. No FileFinder, JSON, subinterpreters, ThreadPool, custom stop/barrier or deadline logic is needed. The exact smaller test reproduced BlockingIOError errno11 before and passed after the unchanged native errno fix on both main and3.15 native Release FT musl cores. The existing strerror test remains unchanged and the full test_os module passes on both corrected runtimes.
|
AI-assisted technical explanation, posted at the author's request. musl’s blocking semaphore path can return success while leaving In CPython, reattachment can park during GC and reach The regression is now a 16-line method in aac344d, using four ordinary threads, GC, |
Preserve the existing errno value across
_PyThreadState_Attach()in release builds as well as debug builds. On a release free-threaded build, reattachment can change errno after a native wait, making valid directory EOF raise spurious EAGAIN.The native change only removes the two
Py_DEBUGconditionals around the existing save/restore. The regression now uses a 16-line method with four ordinary threads, GC andos.listdir, using the existingrun_concurrentlyhelper. No subinterpreter, FileFinder, JSON, ThreadPool or custom shutdown helper is needed.The identical reduced test fails with errno 11 before the native fix and passes afterwards on native release free-threaded musl source builds of both main and 3.15. The complete
test_osmodule then passes both tests on each corrected runtime, with natural GIL off. The earlier retained IO, GC, threading and import qualification covered 2,100 cases on 3.15 and 2,120 on main, with zero failures/errors and their original platform skips; the native patch has not changed. Upstream CI for aac344d completed successfully: all 48 jobs in the Tests workflow, the lint and label workflows, and all 56 check/status contexts were green when verified.Fixes #161769. Includes a NEWS entry. No third-party module or installed SDK is changed.
AI assistance was used for investigation, patch/test preparation and this description. The before/after and standard-library results come from real native source builds.