Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Lib/test/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,18 @@ def __getitem__(self, key):
self.assertEqual(resource.prlimit(0, resource.RLIMIT_AS, BadSeq()),
limits)

# Issue 142317: Setting RLIMIT_STACK not working on Darwin
@unittest.skipIf(sys.platform == "vxworks",
"setting RLIMIT_STACK is not supported on VxWorks")
@unittest.skipUnless(hasattr(resource, 'RLIMIT_FSIZE'), 'requires resource.RLIMIT_FSIZE')
@unittest.skipIf(
sys.platform == "darwin" and support.check_sanitizer(ub=True),
"UBSan on MacOS explicitly compiles with a large stack size which breaks this test"
)
def test_rlimit_stack(self):
resource.setrlimit(
resource.RLIMIT_STACK, resource.getrlimit(resource.RLIMIT_STACK)
)

if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Avoid failures to set RLIMIT_STACK with the resource module by no longer
setting a default stack size for the cpython executable in the standard
build configuration.
17 changes: 12 additions & 5 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3719,18 +3719,25 @@ then
Darwin/*|iOS/*)
LINKFORSHARED="$extra_undefs -framework CoreFoundation"

# Issue #18075: the default maximum stack size (8MBytes) is too
# small for the default recursion limit. Increase the stack size
# to ensure that tests don't crash
stack_size="1000000" # 16 MB
# Use the default stack size (0) unless otherwise requested to
# ensure that modifying RLIMIT_STACK works.
stack_size="0"
if test "$with_ubsan" = "yes"
then
# Undefined behavior sanitizer requires an even deeper stack
stack_size="4000000" # 64 MB
fi

thread_stack_size="$stack_size"
# 0 does not map to a default thread stack size value, so we
# explicitly set the platform default (8MB) here if necessary.
if test "$stack_size" = "0"
then
thread_stack_size="800000"
fi

AC_DEFINE_UNQUOTED([THREAD_STACK_SIZE],
[0x$stack_size],
[0x$thread_stack_size],
[Custom thread stack size depending on chosen sanitizer runtimes.])

if test $ac_sys_system = "Darwin"; then
Expand Down
Loading