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 amaury.forgeotdarc
Recipients amaury.forgeotdarc, loewis
Date 2008-09-29.11:34:09
SpamBayes Score 2.5616596e-09
Marked as misclassified No
Message-id <1222688051.36.0.56998762725.issue3996@psf.upfronthosting.co.za>
In-reply-to
Content
On Windows, PyOS_CheckStack is supposed to protect the interpreter from
stack overflow. But doing this, it always crashes when the stack is
nearly full.

The reason is a bad check of the return value of _resetstkoflw():
according to MSDN, the return value is "Nonzero if the function
succeeds, zero if it fails.":
http://msdn.microsoft.com/en-us/library/89f73td2.aspx

The patch below is enough to replace the "Fatal Python error: Could not
reset the stack!" into a "MemoryError: stack overflow" exception.

Tested with:
>>> loop = None,
>>> for x in xrange(100000): loop = {'x': loop}
...
>>> len(repr(loop))



Index: Python/pythonrun.c
===================================================================
--- Python/pythonrun.c  (revision 66486)
+++ Python/pythonrun.c  (working copy)
@@ -1749,7 +1755,7 @@
                        EXCEPTION_EXECUTE_HANDLER :
                        EXCEPTION_CONTINUE_SEARCH) {
                int errcode = _resetstkoflw();
-               if (errcode)
+               if (errcode == 0)
                {
                        Py_FatalError("Could not reset the stack!");
                }
History
Date User Action Args
2008-09-29 11:34:11amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, loewis
2008-09-29 11:34:11amaury.forgeotdarcsetmessageid: <1222688051.36.0.56998762725.issue3996@psf.upfronthosting.co.za>
2008-09-29 11:34:10amaury.forgeotdarclinkissue3996 messages
2008-09-29 11:34:09amaury.forgeotdarccreate