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.

classification
Title: find_recursion_limit.py is broken
Type: behavior Stage:
Components: Demos and Tools Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, alexandre.vassalotti, pitrou
Priority: high Keywords: easy, needs review, patch

Created on 2008-09-12 20:06 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
find_recursion_limit.patch pitrou, 2008-09-12 20:11
Messages (7)
msg73131 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-09-12 20:06
find_recursion_limit.py in trunk is broken: it fails with an
AttributeError while a RuntimeError is expected. This has appeared due
to the recent changes in recursion limit handling, but the problem is
deeper. As I explained on the ML, functions like PyDict_GetItem()
discard any exception that occur inside them, and return NULL instead.
The caller can then interpret the NULL as an "attribute missing" and
raise AttributeError.

The obvious quick fix is to replace "except RuntimeError" with "except
(RuntimeError, AttributeError)" in find_recursion_limit.py.
msg73134 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-09-12 20:11
Here is a patch.
msg73135 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-09-12 20:17
Could you use PyDict_GetItemWithError() to avoid this?
msg73136 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-09-12 20:19
It's not my code, it's the interpreter's code which uses
PyDict_GetItem() all over the place, and the aim of
find_recursion_limit.py is precisely to test the function call paths
inside the interpreter.
msg73160 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2008-09-13 02:04
The patch seems fine to me.

The docstring at the top of the file says:

It ends when Python causes a segmentation fault because the limit is
too high.  On platforms like Mac and Windows, it should exit with a
MemoryError.

On my Macbook, it segfaults; perhaps that docstring applied only 
to MacOS 9?
msg73178 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-09-13 12:08
> On my Macbook, it segfaults; perhaps that docstring applied only 
> to MacOS 9?

Well, I just tried under Windows and the interpreter neither segfaults
nor prints a MemoryError, it aborts silently. I guess the comment is
either out of date or too optimistic about a supposedly deterministic
behaviour of C stack overflows on those platforms.
msg73196 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-09-13 20:31
Bug fixed and module comments updated in r66457.
History
Date User Action Args
2022-04-11 14:56:39adminsetgithub: 48100
2008-09-13 20:31:48pitrousetstatus: open -> closed
resolution: fixed
messages: + msg73196
2008-09-13 12:08:36pitrousetmessages: + msg73178
2008-09-13 02:04:41akuchlingsetnosy: + akuchling
messages: + msg73160
2008-09-12 20:19:10pitrousetmessages: + msg73136
2008-09-12 20:17:23alexandre.vassalottisetnosy: + alexandre.vassalotti
messages: + msg73135
2008-09-12 20:11:43pitrousetkeywords: + patch, needs review
files: + find_recursion_limit.patch
messages: + msg73134
2008-09-12 20:06:54pitroucreate