Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(28)

Side by Side Diff: Python/ceval.c

Issue 3276: Stack overflow checking dysfunctional with USE_STACKCHECK (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/branches/py3k/
Patch Set: Created 1 year, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* Execute compiled code */ 2 /* Execute compiled code */
3 3
4 /* XXX TO DO: 4 /* XXX TO DO:
5 XXX speed up searching for keywords by using a dictionary 5 XXX speed up searching for keywords by using a dictionary
6 XXX document it! 6 XXX document it!
7 */ 7 */
8 8
9 /* enable more aggressive intra-module optimizations, where available */ 9 /* enable more aggressive intra-module optimizations, where available */
10 #define PY_LOCAL_AGGRESSIVE 10 #define PY_LOCAL_AGGRESSIVE
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 { 464 {
465 PyThreadState *tstate = PyThreadState_GET(); 465 PyThreadState *tstate = PyThreadState_GET();
466 466
467 #ifdef USE_STACKCHECK 467 #ifdef USE_STACKCHECK
468 if (PyOS_CheckStack()) { 468 if (PyOS_CheckStack()) {
469 --tstate->recursion_depth; 469 --tstate->recursion_depth;
470 PyErr_SetString(PyExc_MemoryError, "Stack overflow"); 470 PyErr_SetString(PyExc_MemoryError, "Stack overflow");
471 return -1; 471 return -1;
472 } 472 }
473 #endif 473 #endif
474 _Py_CheckRecursionLimit = recursion_limit;
474 if (tstate->recursion_critical) 475 if (tstate->recursion_critical)
475 /* Somebody asked that we don't check for recursion. */ 476 /* Somebody asked that we don't check for recursion. */
476 return 0; 477 return 0;
477 if (tstate->overflowed) { 478 if (tstate->overflowed) {
478 if (tstate->recursion_depth > recursion_limit + 50) { 479 if (tstate->recursion_depth > recursion_limit + 50) {
479 /* Overflowing while handling an overflow. Give up. */ 480 /* Overflowing while handling an overflow. Give up. */
480 Py_FatalError("Cannot recover from stack overflow."); 481 Py_FatalError("Cannot recover from stack overflow.");
481 } 482 }
482 return 0; 483 return 0;
483 } 484 }
484 if (tstate->recursion_depth > recursion_limit) { 485 if (tstate->recursion_depth > recursion_limit) {
485 --tstate->recursion_depth; 486 --tstate->recursion_depth;
486 tstate->overflowed = 1; 487 tstate->overflowed = 1;
487 PyErr_Format(PyExc_RuntimeError, 488 PyErr_Format(PyExc_RuntimeError,
488 "maximum recursion depth exceeded%s", 489 "maximum recursion depth exceeded%s",
489 where); 490 where);
490 return -1; 491 return -1;
491 } 492 }
492 _Py_CheckRecursionLimit = recursion_limit;
493 return 0; 493 return 0;
494 } 494 }
495 495
496 /* Status code for main loop (reason for stack unwind) */ 496 /* Status code for main loop (reason for stack unwind) */
497 enum why_code { 497 enum why_code {
498 WHY_NOT = 0x0001, /* No error */ 498 WHY_NOT = 0x0001, /* No error */
499 WHY_EXCEPTION = 0x0002, /* Exception occurred */ 499 WHY_EXCEPTION = 0x0002, /* Exception occurred */
500 WHY_RERAISE = 0x0004, /* Exception re-raised by 'finally' */ 500 WHY_RERAISE = 0x0004, /* Exception re-raised by 'finally' */
501 WHY_RETURN = 0x0008, /* 'return' statement */ 501 WHY_RETURN = 0x0008, /* 'return' statement */
502 WHY_BREAK = 0x0010, /* 'break' statement */ 502 WHY_BREAK = 0x0010, /* 'break' statement */
(...skipping 3496 matching lines...) Expand 10 before | Expand all | Expand 10 after
3999 Py_DECREF(l); 3999 Py_DECREF(l);
4000 return NULL; 4000 return NULL;
4001 } 4001 }
4002 PyList_SetItem(l, i, x); 4002 PyList_SetItem(l, i, x);
4003 } 4003 }
4004 return l; 4004 return l;
4005 #endif 4005 #endif
4006 } 4006 }
4007 4007
4008 #endif 4008 #endif
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r483