Re: setrecursionlimit

2016-05-19 Thread Nobody
On Wed, 18 May 2016 09:19:25 -0700, Ned Batchelder wrote: > Is there a way to know how large the C stack can grow, Yes. For the main thread, getrlimit(RLIMIT_STACK). For other threads, pthread_attr_getstacksize(). > and how much it will grow for each Python function call? No. Depending upon th

Re: setrecursionlimit

2016-05-19 Thread Oscar Benjamin
On 18 May 2016 at 17:11, Steven D'Aprano wrote: > The documentation for setrecursion limit warns against setting the limit too > high: > > [quote] > The highest possible limit is platform-dependent. A user may need to > set the limit higher when they have a program that requires deep >

Re: setrecursionlimit

2016-05-19 Thread Gregory Ewing
Rustom Mody wrote: Both the mess in catching numeric overflow as well as stackoverflow looks like its C's fault. I consider it as the fault of currently fashionable stock hardware The sad thing about C is that it doesn't even help you detect integer overflow in *software*. Every machine I've

Re: setrecursionlimit

2016-05-19 Thread Gregory Ewing
Steven D'Aprano wrote: I don't really understand why the system can't track the current top of the stack and bottom of the heap, and if they're going to collide, halt the process. That effectively *is* what it does. The reason it manifests as a segfault is because of the way it goes about dete

Re: setrecursionlimit

2016-05-18 Thread Rustom Mody
On Thursday, May 19, 2016 at 3:13:44 AM UTC+5:30, bream wrote: > On Wednesday, May 18, 2016 at 6:47:42 PM UTC+1, Chris Kaynor wrote: > > On Wed, May 18, 2016 at 10:15 AM, Steven D'Aprano wrote: > > > > > I don't really understand why the system can't track the current top of > > > the > > > stack

Re: setrecursionlimit

2016-05-18 Thread Christian Gollwitzer
Am 18.05.16 um 19:15 schrieb Steven D'Aprano: Not being a C programmer, I don't really understand this. The idea I have in mind is a model of program memory I learned[1] way back in the 80s. I don't know if it's still valid. Your application has a bunch of memory available, which broadly speakin

Re: setrecursionlimit

2016-05-18 Thread Chris Kaynor
On Wed, May 18, 2016 at 10:15 AM, Steven D'Aprano wrote: > I don't really understand why the system can't track the current top of the > stack and bottom of the heap, and if they're going to collide, halt the > process. That would still be kinda awful, in a sudden "your application > just died" k

Re: setrecursionlimit

2016-05-18 Thread Ian Kelly
On Wed, May 18, 2016 at 11:15 AM, Steven D'Aprano wrote: > I don't really understand why the system can't track the current top of the > stack and bottom of the heap, and if they're going to collide, halt the > process. That would still be kinda awful, in a sudden "your application > just died" ki

Re: setrecursionlimit

2016-05-18 Thread Steven D'Aprano
On Thu, 19 May 2016 02:29 am, Rob Gaddi wrote: > Ned Batchelder wrote: >> Is there a way to know how large the C stack can grow, and how much it >> will grow for each Python function call? That sounds complicated to get >> right. >> >> --Ned. > > It's probably trivial to look at a number and say

Re: setrecursionlimit

2016-05-18 Thread Chris Kaynor
On Wed, May 18, 2016 at 9:19 AM, Ned Batchelder wrote: > I believe the issue here is that Python recursion results in the C stack > growing. Each Python function call creates a number of C function calls, > which grows the C stack. The crash you see is the C stack overflowing. > > Is there a wa

Re: setrecursionlimit

2016-05-18 Thread Rob Gaddi
Ned Batchelder wrote: > On Wednesday, May 18, 2016 at 12:11:25 PM UTC-4, Steven D'Aprano wrote: >> The documentation for setrecursion limit warns against setting the limit too >> high: >> >> [quote] >> The highest possible limit is platform-dependent. A user may need to >> set the lim

Re: setrecursionlimit

2016-05-18 Thread Ned Batchelder
On Wednesday, May 18, 2016 at 12:11:25 PM UTC-4, Steven D'Aprano wrote: > The documentation for setrecursion limit warns against setting the limit too > high: > > [quote] > The highest possible limit is platform-dependent. A user may need to > set the limit higher when they have a prog