Skip to content
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
00fe666
gh-141044: Fix ASan leak with small threading.stack_size()
KingLizard1020 Sep 17, 2026
3aef310
gh-141044: Require 6 stack margins on debug builds too
KingLizard1020 Sep 21, 2026
09dc0cb
gh-141044: Update NEWS for debug/sanitizer 6-margin floor
KingLizard1020 Sep 21, 2026
04ebedb
gh-141044: Portable 127 KiB stack_size rejection check
KingLizard1020 Sep 21, 2026
bfbf64c
gh-141044: Restore test_thread.py (undo accidental PLACEHOLDER)
KingLizard1020 Sep 21, 2026
7f942ca
gh-141044: Silence NEWS Sphinx nit for _thread.stack_size
KingLizard1020 Sep 21, 2026
1fac29a
gh-141044: Raise TSan stack_size floor to 12 margins
KingLizard1020 Sep 21, 2026
0f0971d
gh-141044: Update NEWS for TSan 12-margin stack_size floor
KingLizard1020 Sep 21, 2026
f2242a1
gh-141044: Allow stack_size tests to skip 256 KiB under TSan
KingLizard1020 Sep 21, 2026
4d72b7e
gh-141044: Skip 256 KiB stack tests when below TSan floor
KingLizard1020 Sep 21, 2026
c15bbbd
temp: canary for restore path (will remove)
KingLizard1020 Sep 21, 2026
ab3acf1
temp: escape-test canary (will remove)
KingLizard1020 Sep 21, 2026
c43e6b8
wip: restore test_threading.py (5KB partial)
KingLizard1020 Sep 21, 2026
d012c29
temp: remove restore canary
KingLizard1020 Sep 21, 2026
12213d2
test @file
KingLizard1020 Sep 21, 2026
bb6fe83
wip: restore test_threading.py (5KB partial, undo @path probe)
KingLizard1020 Sep 21, 2026
124b140
gh-141044: Fix Docs soft-deprecated KeyError in changes builder
KingLizard1020 Sep 21, 2026
f609ce4
Add cpy test_threading restore part _cpy_tt_part_0.b64 (no trigger)
KingLizard1020 Sep 21, 2026
fe78d4b
Add cpy test_threading restore part _cpy_tt_part_1.b64 (no trigger)
KingLizard1020 Sep 21, 2026
4eb90e5
Fix part1 chunk0 of cpy test_threading restore
KingLizard1020 Sep 21, 2026
6222f46
Restore threading regression tests and update from main
KingLizard1020 Sep 22, 2026
de3886e
Fix threading tests for sanitizer stack minimum
KingLizard1020 Sep 22, 2026
be750c5
Merge upstream main into PR #157691
KingLizard1020 Sep 23, 2026
af31989
Merge branch 'main' into cursor/fix-threading-stack-size-leak-a999
KingLizard1020 Sep 24, 2026
db9370d
Merge remote-tracking branch 'upstream/main' into cursor/fix-threadin…
KingLizard1020 Oct 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
gh-141044: Require 6 stack margins on debug builds too
Py_DEBUG (and UBSan) share the larger stack margin with ASan/TSan, but
still used a 3-margin minimum. threading.Thread bootstrap then leaked
references at that floor; the new refcount test failed on Ubuntu/macOS
CI. Align the minimum with ASan/TSan. Release builds stay at 3 margins.
  • Loading branch information
KingLizard1020 committed Sep 21, 2026
commit 3aef3107dabcdade64a9567dd6b707598a90632f
17 changes: 11 additions & 6 deletions Include/internal/pycore_pythonrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@ extern PyObject* _PyRun_SimpleString(
# define _PyOS_STACK_MARGIN_SHIFT (_PyOS_LOG2_STACK_MARGIN + 2)
#endif

#if defined(_Py_THREAD_SANITIZER) || defined(_Py_ADDRESS_SANITIZER)
/* Sanitizer builds need more than the default 3 margins:
#if (defined(Py_DEBUG) \
|| defined(_Py_ADDRESS_SANITIZER) \
|| defined(_Py_THREAD_SANITIZER) \
|| defined(_Py_UNDEFINED_BEHAVIOR_SANITIZER))
/* Debug and sanitizer builds need more than the default 3 margins:
* - TSan: tstate_set_stack() only uses half the stack.
* - ASan (gh-141044): instrumentation consumes extra C stack, so 3
* margins leave threading.Thread bootstrap with no working space
* above the soft recursion limit and leak thread objects. */
* - ASan (gh-141044): instrumentation consumes extra C stack.
* - Py_DEBUG / UBSan: larger C frames leave threading.Thread bootstrap
* with no working space above the soft recursion limit at 3 margins,
* leaking thread objects (same failure mode as ASan).
* Require 6 margins, matching the builds that already use a larger
* _PyOS_LOG2_STACK_MARGIN above. Release builds stay at 3. */
# define _PyOS_MIN_STACK_SIZE (_PyOS_STACK_MARGIN_BYTES * 6)
#else
# define _PyOS_MIN_STACK_SIZE (_PyOS_STACK_MARGIN_BYTES * 3)
Expand All @@ -78,4 +84,3 @@ extern PyObject* _PyRun_SimpleString(
}
#endif
#endif // !Py_INTERNAL_PYTHONRUN_H