Natanael Copa <natanael.c...@docker.com> added the comment:

With "bad assumption" I mean that currently the code assumes that all unknown 
systems has big enough default thread stack size. This would not be a "bad 
assumption" if POSIX (or any other standard) would specify a requirement on the 
default stack size. To my understanding, there are no such requirement in the 
spec, and thus, applications can not really assume anything about the default 
thread stack size.

musl libc does not provide any __MUSL__ macro by design, because they consider 
"it’s a bug to assume a certain implementation has particular properties rather 
than testing" so we cannot really make exception for musl.

https://wiki.musl-libc.org/faq.html#Q:_Why_is_there_no_<code>__MUSL__</code>_macro?

I think the options we have are:
- at run time, use pthread_attr_getstacksize() to verify we have enough stack 
size. I don't know how to calculate the proper minimum, but some testing showed 
that we need 450k on musl x86_64 to reach sys.getrecursionlimit() so I'd say 
1MB is a good limit - atleast for x86_64.
- at build time, run pthread_attr_getstacksize() from configure script to 
detect default stack size. This will not work for cross compile.
- reverse the current #ifdef behavior so that we check for known systems that 
has big enough system default (eg __GLIBC__ etc) and then fall back to 
something safe for everything else.
- Do nothing. Systems with low stack needs to figure out to add 
-DTHREAD_STACK_SIZE=0x100000 to the CFLAGS (this is what Alpine does right now)

I can of course make a check for musl in the configure script and special case 
it, but it still does not fix the issue: There is no guarantee that stack size 
is big enough for python's use for every existing and unknown future system.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32307>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to