Message74024
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!");
} |
|
Date |
User |
Action |
Args |
2008-09-29 11:34:11 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, loewis |
2008-09-29 11:34:11 | amaury.forgeotdarc | set | messageid: <1222688051.36.0.56998762725.issue3996@psf.upfronthosting.co.za> |
2008-09-29 11:34:10 | amaury.forgeotdarc | link | issue3996 messages |
2008-09-29 11:34:09 | amaury.forgeotdarc | create | |
|