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: Ctypes C-level infinite recursion
Type: crash Stage: resolved
Components: ctypes Versions: Python 3.1, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: theller Nosy List: BreamoreBoy, ajaksu2, alex, amaury.forgeotdarc, arigo, fijal, gvanrossum, python-dev, theller
Priority: low Keywords: patch

Created on 2008-01-16 09:38 by fijal, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
crash.py fijal, 2008-01-16 09:38
python_recursive_as_parameter.diff alex, 2010-09-20 00:14
python_recursive_as_parameter.diff alex, 2010-09-20 13:37
Messages (10)
msg59993 - (view) Author: Maciek Fijalkowski (fijal) Date: 2008-01-16 09:38
Code in example abuses the fact that _as_parameter_ is passed
recursively. Not sure if this is for fixing or not.
msg59996 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-16 15:03
I've got a hunch that any crashes you cause with ctypes are your own
fault. :-)
msg87911 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-05-16 19:37
Confirmed in trunk and py3k. Maybe we should treat ctypes segfaults that
don't involve external C code more strictly as bugs?
msg116867 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-19 12:11
I'm not convinced that this needs doing, so I'll close in a couple of weeks unless anyone objects.
msg116874 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2010-09-19 15:03
I concur with Daniel, this strikes me as a legitimate bug.  Crashing is obviously possibly by calling into arbitrary C code, but in this case control never leaves the runtime.
msg116890 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2010-09-19 22:31
So has anyone got an idea on how to fix this without solving the halting problem?
msg116898 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2010-09-20 00:14
No need to solve the halting problem, just to detect a cycle in data.  I've got a patch, however it requires objects to be hashable.  Another case for identity dict I suppose :)  Not sure if that's a reasonable requirement, in any event, proof of concept patch, against trunk.
msg116914 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-09-20 06:48
This function is called quite often. Building a set each time will be expensive.
What about a simpler recursion check with Py_EnterRecursiveCall()?
msg116934 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2010-09-20 13:37
Good idea Amaury, seems to work just fine.
msg132281 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-03-26 23:16
New changeset 4945a45b8be4 by Benjamin Peterson in branch '3.1':
check possible recursive _as_parameter_ to prevent segfault (closes #1838)
http://hg.python.org/cpython/rev/4945a45b8be4

New changeset 4bd06503eaca by Benjamin Peterson in branch '2.7':
check possible recursive _as_parameter_ to prevent segfault (closes #1838)
http://hg.python.org/cpython/rev/4bd06503eaca
History
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 46160
2011-03-26 23:16:49python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg132281

resolution: fixed
stage: test needed -> resolved
2010-09-20 13:37:52alexsetfiles: + python_recursive_as_parameter.diff

messages: + msg116934
2010-09-20 06:48:43amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg116914
2010-09-20 00:14:39alexsetfiles: + python_recursive_as_parameter.diff
keywords: + patch
messages: + msg116898
2010-09-19 22:31:40gvanrossumsetmessages: + msg116890
2010-09-19 15:03:26alexsetstatus: pending -> open
nosy: + alex
messages: + msg116874

2010-09-19 12:11:41BreamoreBoysetstatus: open -> pending
nosy: + BreamoreBoy
messages: + msg116867

2009-05-16 19:37:09ajaksu2setversions: + Python 3.1
nosy: + ajaksu2

messages: + msg87911

stage: test needed
2008-08-24 22:33:48nnorwitzsetassignee: theller
components: + ctypes, - Extension Modules
nosy: + theller
2008-01-16 15:03:52gvanrossumsetpriority: low
nosy: + gvanrossum
messages: + msg59996
2008-01-16 09:38:43fijalcreate