[issue41912] Long generator chain causes segmentation fault

2020-10-04 Thread Tim Peters
Tim Peters added the comment: "Stackless" is a large topic with a convoluted history. Do the web search. In short, no, it will never go in the core - too disruptive to too many things. Parts have lived on in other ways, watered down versions. The PyPy project captured most of what remains,

[issue41912] Long generator chain causes segmentation fault

2020-10-02 Thread Tom Karzes
Tom Karzes added the comment: Thanks Tim and Terry. Stackless Python sounds interesting. It's nice to know that others had the same idea I did, although I tend to shy away from exotic variants since they tend to be less well-supported. Any chance that CPython will go stackless at some

[issue41912] Long generator chain causes segmentation fault

2020-10-02 Thread Tim Peters
Tim Peters added the comment: Right, generators played no essential role here. Just one way of piling up a tall tower of C stack frames. Search the web for "stackless Python" for the history of attempts to divorce the CPython implementation from the platform C stack. There are ways to

[issue41912] Long generator chain causes segmentation fault

2020-10-02 Thread Terry J. Reedy
Terry J. Reedy added the comment: Another "We are not responsible, proceed at your own risk" operation is importing ctypes, which allows one to overwrite bytes in the running python. -- nosy: +terry.reedy resolution: -> not a bug stage: -> resolved status: open -> closed

[issue41912] Long generator chain causes segmentation fault

2020-10-02 Thread Tom Karzes
Tom Karzes added the comment: I tested this some more, and one thing became clear that I hadn't realized before: This bug has nothing to do specifically with generators (as I had thought), but is in fact due purely to the recursion limit. I created a recursive test program that doesn't use

[issue41912] Long generator chain causes segmentation fault

2020-10-02 Thread Tim Peters
Tim Peters added the comment: There is no way in portable ANSI C to deduce a "safe" limit. The limits that exist were picked by hand across platforms, to be conservative guesses at what would "never" break. You're allowed to increase the limit if you think you know better - and you may! No

[issue41912] Long generator chain causes segmentation fault

2020-10-02 Thread Tom Karzes
Tom Karzes added the comment: That is a good point, except I don't believe the value needed to expose this bug is a "too-high limit" (as the documentation calls it). I set it to 100100 for convenience, but in practice even a value of 17000 is more than enough to expose the bug on my system

[issue41912] Long generator chain causes segmentation fault

2020-10-02 Thread Tim Peters
Tim Peters added the comment: The docs are already clear about that you play with `setrecursionlimit()` at your own risk: """ Set the maximum depth of the Python interpreter stack to limit. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python.

[issue41912] Long generator chain causes segmentation fault

2020-10-02 Thread Tom Karzes
New submission from Tom Karzes : If I create a sufficiently long chain of generators, I encounter a segmentation fault. For example, the following works as expected: % ./gen_bug3.py 1 1 % But for sufficiently larger chain lengths, it seg faults: % ./gen_bug3.py