| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
On Linux when Python is linked to the musl C library, use a thread stack size of at least 1 MiB instead of musl default which is 128 kiB.
|
On "AMD64 Alpine Linux NoGIL 3.x" buildbot, currently test_threading.test_recursion_limit() does crash with a stack overflow: issue gh-148260. With this change, Python is built with -Wl,-z,stack-size=1048576 linker flag and so uses a thread stack size of 1 MiB by default, instead of musl default which is 128 kiB. With this change, test_threading.test_recursion_limit() does pass. I tested Python built in debug mode (gcc -O3) and release mode (gcc -Og), with and without the GIL (--disable-gil). The buildbot worker uses ./configure --with-pydebug --disable-gil. |
Sorry, something went wrong.
|
@corona10 @erlend-aasland @picnixz: I'm looking for autotools experts to review my configure.ac change. I'm not comfortable with changing the build system. Currently, the ./configure script doesn't run a built C program, it only uses AC_LINK_IFELSE or AC_COMPILE_IFELSE to check if a C program can be built or linked. It seems like running a program is the only way to check if Python is linked to the musl library. My change is not specific to the musl library, but instead read the default thread stack size to decide if -Wl,-z,stack-size=1048576 linker flag should be used. My configure.ac is inspired by Python 3.12 ./configure script which runs $CPP $CPPFLAGS conftest.c >conftest.out to read the output of the C preprocessor. But my change is different since it compiles a C program and then runs the C program. The code is skipped if Python is cross-compiled. |
Sorry, something went wrong.
| EOF | ||
|
|
||
| ac_cv_thread_stack_size="default" | ||
| if $CC -pthread $CFLAGS conftest.c -o conftest &>/dev/null; then |
There was a problem hiding this comment.
I chose to use $CC -pthread to make sure that the pthread API can be used in the C program. We check if -pthread is supported above, near line 3064, which sets CC="$CC -pthread" if the flag is supported. I should maybe omit -pthread and move my code after the -pthread check.
Sorry, something went wrong.
There was a problem hiding this comment.
I think using -pthread explicitly is fine, it doesn't matter if it's passed to the compiler twice.
Sorry, something went wrong.
|
!buildbot Alpine |
Sorry, something went wrong.
|
🤖 New build scheduled with the buildbot fleet by @zware for commit fd078ac 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F149993%2Fmerge The command will test the builders whose names match following regular expression: Alpine The builders matched are:
|
Sorry, something went wrong.
|
Cool, the test suite passed on Alpine Linux buildbots:
|
Sorry, something went wrong.
| EOF | ||
|
|
||
| ac_cv_thread_stack_size="default" | ||
| if $CC -pthread $CFLAGS conftest.c -o conftest &>/dev/null; then |
There was a problem hiding this comment.
I think using -pthread explicitly is fine, it doesn't matter if it's passed to the compiler twice.
Sorry, something went wrong.
| ac_cv_thread_stack_size="default" | ||
| if $CC -pthread $CFLAGS conftest.c -o conftest &>/dev/null; then | ||
| ./conftest &>/dev/null | ||
| if test $? -eq 1; then |
There was a problem hiding this comment.
For debugging it would probably be nice if the output said whether the stack size is good enough, needs overriding or just unknown (return code 2)
Sorry, something went wrong.
There was a problem hiding this comment.
The possible exit codes are:
The two possible outputs are:
Do you mean that the error case should be rendered differently, such as "error"? Usually, it seems like configure ignores errors silently.
Sorry, something went wrong.
There was a problem hiding this comment.
I mean I would like the output to be "checking for the thread stack size... unknown". It can keep behaving like 'default', but at least from the configure output it'll be more obvious it wasn't able to detect the actual thread size. But it's not a big deal if it's too tricky to get right.
Sorry, something went wrong.
There was a problem hiding this comment.
Ok, I modified the code to display "error" if gcc/clang failed to build the C program, or if the C program failed (exit code differently than 0 and 1).
Sorry, something went wrong.
|
!buildbot Alpine |
Sorry, something went wrong.
|
🤖 New build scheduled with the buildbot fleet by @vstinner for commit 86027a6 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F149993%2Fmerge The command will test the builders whose names match following regular expression: Alpine The builders matched are:
|
Sorry, something went wrong.
The worker is down at the moment; I had a storm-related power outage this morning and my UPS has not yet recharged enough to turn the host back on. It will be back by this afternoon. |
Sorry, something went wrong.
It works as expected:
On "AMD64 Alpine Linux NoGIL PR", test_threading crashed :-( But it passed when rerun... 0:03:47 load avg: 6.33 [255/505/1] test_threading worker non-zero exit code (Exit code -11 (SIGSEGV)) -- running (1): test_compileall (30.8 sec) (...) test_start_thread_again (test.test_threading.ThreadingExceptionTests.test_start_thread_again) ... ok test_concurrent_tee_negative_n (test.test_threading.ThreadingIteratorToolsTests.test_concurrent_tee_negative_n) ... ok test_concurrent_tee_supports_concurrent_consumers (test.test_threading.ThreadingIteratorToolsTests.test_concurrent_tee_supports_concurrent_consumers) ... (...) 0:08:02 load avg: 3.48 Run 1 test in parallel using 1 worker process (timeout: 30 min, worker timeout: 35 min) 0:08:26 load avg: 2.66 [1/1] test_threading passed (...) |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15. |
Sorry, something went wrong.
|
GH-150150 is a backport of this pull request to the 3.15 branch. |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
Sorry, something went wrong.
|
GH-151586 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
On Linux when Python is linked to the musl C library, use a thread stack size of at least 1 MiB instead of musl default which is 128 kiB.