diff options
author | Sam Gross <colesbury@gmail.com> | 2025-03-11 10:33:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-11 10:33:23 -0400 |
commit | 4162bc133b21ccb06d3589bd69ddb7bb248c58d2 (patch) | |
tree | 8a402eb4a69a929de3931a1f11cfcd829d118c1f /Python | |
parent | 19081158713526a3042c2ad3c6d5a589579b420f (diff) | |
download | cpython-4162bc133b21ccb06d3589bd69ddb7bb248c58d2.tar.gz cpython-4162bc133b21ccb06d3589bd69ddb7bb248c58d2.zip |
gh-130396: Fix thread sanitizer crashes on stack overflow tests (gh-130966)
Thread sanitizer will often crash if a test uses more than half the
stack.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index a702d296e22..f9089d7f11f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -392,7 +392,12 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate) if (err == 0) { uintptr_t base = ((uintptr_t)stack_addr) + guard_size; _tstate->c_stack_top = base + stack_size; +#ifdef _Py_THREAD_SANITIZER + // Thread sanitizer crashes if we use a bit more than half the stack. + _tstate->c_stack_soft_limit = base + (stack_size / 2); +#else _tstate->c_stack_soft_limit = base + PYOS_STACK_MARGIN_BYTES * 2; +#endif _tstate->c_stack_hard_limit = base + PYOS_STACK_MARGIN_BYTES; assert(_tstate->c_stack_soft_limit < here_addr); assert(here_addr < _tstate->c_stack_top); |