This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients Vasyl Kolomiets, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2018-01-18.15:05:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516287920.01.0.467229070634.issue32570@psf.upfronthosting.co.za>
In-reply-to
Content
CPython pushes a frame on the thread's stack for every Python frame. By default in Windows Python the thread's stack is allowed to grow up to about 2 MB. On Linux the default limit is 8 MB, but a higher limit can be set via `ulimit -s`. After the stack is full, pushing another value will crash the process due to a stack overflow. Windows raises a STATUS_STACK_OVERFLOW (0xC00000FD) exception. Linux raises a SIGSEGV signal (segmentation fault).

The default interpreter recursion limit of 1,000 is set to raise a Python RecursionError well before you'd see a hard crash from a stack overflow. If we ballpark a C stack frame at about 1 KB in 64-bit Python, then the default stack size on Windows should support a recursion limit of about 2,000. For a recursion limit of 100,000, I would estimate a 100 MB stack size.

You can call threading.stack_size(size_in_bytes) to reserve a larger stack size for new threads. However, in Python code it's better to rewrite such deeply recursive cases to use loops instead.
History
Date User Action Args
2018-01-18 15:05:20eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, Vasyl Kolomiets
2018-01-18 15:05:20eryksunsetmessageid: <1516287920.01.0.467229070634.issue32570@psf.upfronthosting.co.za>
2018-01-18 15:05:19eryksunlinkissue32570 messages
2018-01-18 15:05:19eryksuncreate