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.
Created on 2011年07月04日 00:56 by rfk, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| ctypes_gcuntrack.patch | rfk, 2011年07月04日 00:56 | review | ||
| Messages (6) | |||
|---|---|---|---|
| msg139724 - (view) | Author: Ryan Kelly (rfk) | Date: 2011年07月04日 00:56 | |
According to the docs here: http://docs.python.org/c-api/gcsupport.html Any object that uses PyObject_GC_Track in its constructor must call PyObject_GC_UnTrack in its deallocator. The CThunkObject in _ctypes does the former but not the later. Attached patch adds a call to PyObject_GC_UnTrack. This doesn't fix any particular bug I was seeing, I just happened to be going through the _ctypes sources (you know, for fun...) and noticed this discrepancy. |
|||
| msg143852 - (view) | Author: Meador Inge (meador.inge) * (Python committer) | Date: 2011年09月11日 03:08 | |
This patch seems reasonable, is consistent with the GC docs, and passed all regression tests. Can someone apply? |
|||
| msg143916 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2011年09月12日 16:07 | |
I was going to say that the patch has no visible effect, since PyObject_GC_Del() calls something which has the same effect as PyObject_GC_Untrack...
But the following code crashes the interpreter! And of course the patch fixes it...
import ctypes, gc
class Nasty:
def __del__(self):
gc.collect()
ctypes.CFUNCTYPE(None)(lambda x=Nasty(): None)
print("OK")
|
|||
| msg143929 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年09月12日 19:20 | |
New changeset eb9f566fd8db by Amaury Forgeot d'Arc in branch '2.7': Issue #12483: ctypes: Fix a crash when the destruction of a callback http://hg.python.org/cpython/rev/eb9f566fd8db New changeset eae8e4ab0455 by Amaury Forgeot d'Arc in branch '3.2': Issue #12483: ctypes: Fix a crash when the destruction of a callback http://hg.python.org/cpython/rev/eae8e4ab0455 New changeset fe125a3fda54 by Amaury Forgeot d'Arc in branch 'default': Merge 3.2: Issue #12483: ctypes: Fix a crash when the destruction of a callback http://hg.python.org/cpython/rev/fe125a3fda54 |
|||
| msg143931 - (view) | Author: Meador Inge (meador.inge) * (Python committer) | Date: 2011年09月12日 19:36 | |
Heh, I was just about to upload another patch with your test case. Thanks for committing this Amaury. |
|||
| msg143932 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2011年09月12日 19:40 | |
Thanks for your help! I fear they are many other places like this one in CPython code. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56692 |
| 2011年09月12日 19:40:11 | amaury.forgeotdarc | set | messages: + msg143932 |
| 2011年09月12日 19:36:27 | meador.inge | set | status: open -> closed resolution: fixed messages: + msg143931 stage: patch review -> resolved |
| 2011年09月12日 19:20:20 | python-dev | set | nosy:
+ python-dev messages: + msg143929 |
| 2011年09月12日 16:07:59 | amaury.forgeotdarc | set | messages: + msg143916 |
| 2011年09月11日 03:08:12 | meador.inge | set | nosy:
+ amaury.forgeotdarc, meador.inge, belopolsky messages: + msg143852 type: behavior stage: patch review |
| 2011年07月04日 00:56:40 | rfk | create | |