Skip to content

Commit

Permalink
python*: set thread stack size on musl
Browse files Browse the repository at this point in the history
Ensure recursion limit is reached before stack overflow.

Python does this for OSX and BSD:
https://github.com/python/cpython/blob/13ff24582c99dfb439b1af7295b401415e7eb05b/Python/thread_pthread.h#L22

Size of 1MB chosen to match value in Alpine:
https://git.alpinelinux.org/cgit/aports/commit/main/python2/APKBUILD?id=2f35283fec8ec451fe5fb477dd32ffdcc0776e89

Manual testing via Alpine's test-stacksize.py crashes on these
previously, and works with these changes.
  • Loading branch information
dtzWill committed Mar 20, 2018
1 parent 7e44f19 commit 9aa2219
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkgs/development/interpreters/python/cpython/2.7/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ in stdenv.mkDerivation {
LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
inherit (mkPaths buildInputs) C_INCLUDE_PATH LIBRARY_PATH;

NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2"
+ optionalString hostPlatform.isMusl " -DTHREAD_STACK_SIZE=0x100000";
DETERMINISTIC_BUILD = 1;

setupHook = python-setup-hook sitePackages;
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/interpreters/python/cpython/3.4/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ in stdenv.mkDerivation {
${optionalString stdenv.isDarwin ''
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2"
export MACOSX_DEPLOYMENT_TARGET=10.6
''
+ optionalString stdenv.hostPlatform.isMusl ''
export NIX_CFLAGS_COMPILE+=" -DTHREAD_STACK_SIZE=0x100000"
''}
'';

Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/interpreters/python/cpython/3.5/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ in stdenv.mkDerivation {
${optionalString stdenv.isDarwin ''
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2"
export MACOSX_DEPLOYMENT_TARGET=10.6
''
+ optionalString stdenv.hostPlatform.isMusl ''
export NIX_CFLAGS_COMPILE+=" -DTHREAD_STACK_SIZE=0x100000"
''}
'';

Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/interpreters/python/cpython/3.6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ in stdenv.mkDerivation {
${optionalString stdenv.isDarwin ''
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2"
export MACOSX_DEPLOYMENT_TARGET=10.6
''
+ optionalString stdenv.hostPlatform.isMusl ''
export NIX_CFLAGS_COMPILE+=" -DTHREAD_STACK_SIZE=0x100000"
''}
'';

Expand Down

0 comments on commit 9aa2219

Please sign in to comment.