On 1/19/2021 8:31 AM, Mark Shannon wrote:

It's time for yet another PEP :)

Fortunately, this one is a small one that doesn't change much.
It's aim is to make the VM more robust.

Abstract
========

This PEP proposes that machine stack overflow is treated differently from runaway recursion.

My impression is that this is already the case in the sense given below.

https://bugs.python.org/issue42887 is about segfaults with this code with no Python-level recursion.

mystr  = "hello123"
for x in range(1000000):
    mystr = mystr.__sizeof__()

Christian Heimes reproduced and said "The stack trace is several hundred thousand (!) levels deep." Ronald Oussoren said "The dealloc of "mystr" will cause recursive calls to tp_dealloc along the entire chain and that can exhaust the C stack."

Since hundreds of thousands is a lot bigger than 1000, I assume that the C recursion is not tracked. Whick is to say, recursive C calls are not counted, unlike recursive Python calls. There have been several issues about highly nested code and recursive structures causes segfaults, presumably due to C level recursion. These are usually closed as 'Won't fix' and the suggestion 'don't do that'.

I strongly agree that a fix would be great.

--
Terry Jan Reedy
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/4NA42RO7E5XV75WHWBEFVSJMFHJ7FCUJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to