gh-139653: Remove assertions in _Py_InitializeRecursionLimits() by vstinner · Pull Request #141551 · python/cpython
This PR is to repair FreeBSD and Alpine buildbots. These buildbot workers were crashing randomly (with an assertion error in fact). I suppose that WASI had the same issue but it was more likely on WASI so I already skipped the assertion on WASI.
If an assertion is failing, fix whatever is causing the invariant to be broken. Don't just remove the assert.
It's the following assertion which fails randomly:
uintptr_t here_addr = _Py_get_machine_stack_pointer(); .... assert(here_addr < ts->c_stack_top);
The code to get the stack top in hardware_stack_limits() is not reliable:
uintptr_t top_addr = _Py_SIZE_ROUND_UP(here_addr, 4096);
Maybe one problem is that the assertion is not checked in the same function than hardware_stack_limits().
I don't have time to investigate this issue right now.
I suppose that you should be able to reproduce it if you disable the pthread_attr_getstack() code path in hardware_stack_limits().