You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
visit_decref(): add an assertion to check that the object is not freed #82251
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2019-09-18.12:10:58.170>created_at=<Date2019-09-09.14:05:36.804>labels= ['interpreter-core', 'type-feature', '3.8', '3.9']
title='visit_decref(): add an assertion to check that the object is not freed'updated_at=<Date2019-10-16.01:37:51.802>user='https://github.com/vstinner'
msg351473 example with the new assertion and enhanced debug functions:
--- Modules/gcmodule.c:379: visit_decref: Assertion "!_PyObject_IsFreed(op)" failed
<object at 0x7ff0038956d0 is freed>
Fatal Python error: _PyObject_AssertFailed
Python runtime state: finalizing (tstate=0x1d1c9b0)
Activity
vstinner commentedon Sep 9, 2019
This issue is related to bpo-36389 "Add gc.enable_object_debugger(): detect corrupted Python objects in the GC.
I propose to call _PyObject_IsFreed() in visit_decref() in debug mode, to get a better error message if something goes wrong.
visit_decref() is commonly found in C traceback (ex: gdb backtrace) of bugs related to the garbage collector.
vstinner commentedon Sep 9, 2019
Example with attached bpo-38037-bug.patch: you can apply this patch on the master branch to reintroduce bpo-38037 bug.
vstinner@apu$ git apply bpo-38037-bug.patch
vstinner@apu$ make
Without PR 15782:
vstinner@apu$ ./python -c pass
Segmentation fault (core dumped)
With PR 15782:
vstinner@apu$ ./python -c pass
Modules/gcmodule.c:379: visit_decref: Assertion "!_PyObject_IsFreed(op)" failed
<object: freed>
Fatal Python error: _PyObject_AssertFailed
Current thread 0x00007f171a280740 (most recent call first):
Aborted (core dumped)
The bug is catched earlier. And Python provides more information.
vstinner commentedon Sep 9, 2019
New changeset d91d4de by Victor Stinner in branch 'master':
bpo-38070: visit_decref() calls _PyObject_IsFreed() (GH-15782)
d91d4de
miss-islington commentedon Sep 9, 2019
New changeset 5731172 by Miss Islington (bot) in branch '3.8':
bpo-38070: visit_decref() calls _PyObject_IsFreed() (GH-15782)
5731172
pablogsal commentedon Sep 10, 2019
Should this be closed now?
vstinner commentedon Sep 10, 2019
Please keep it open, I have a few more local changess to enhance Py_FatalError() :-) I would like to reuse the bpo number.
vstinner commentedon Sep 17, 2019
New changeset 8fa3e17 by Victor Stinner in branch 'master':
bpo-38070: _Py_DumpTraceback() writes <no Python frame> (GH-16244)
8fa3e17
vstinner commentedon Sep 17, 2019
New changeset b39afb7 by Victor Stinner in branch 'master':
bpo-38070: Enhance _PyObject_Dump() (GH-16243)
b39afb7
vstinner commentedon Sep 17, 2019
New changeset d3b9041 by Victor Stinner in branch 'master':
bpo-38070: Add _PyRuntimeState.preinitializing (GH-16245)
d3b9041
vstinner commentedon Sep 17, 2019
New changeset 1ce16fb by Victor Stinner in branch 'master':
bpo-38070: Py_FatalError() logs runtime state (GH-16246)
1ce16fb
vstinner commentedon Sep 17, 2019
msg351473 example with the new assertion and enhanced debug functions:
---
Modules/gcmodule.c:379: visit_decref: Assertion "!_PyObject_IsFreed(op)" failed
<object at 0x7ff0038956d0 is freed>
Fatal Python error: _PyObject_AssertFailed
Python runtime state: finalizing (tstate=0x1d1c9b0)
Current thread 0x00007ff010841740 (most recent call first):
<no Python frame>
Aborted (core dumped)
---
vstinner commentedon Sep 18, 2019
New changeset 47bbab9 by Victor Stinner in branch '3.8':
[3.8] bpo-38070: Py_FatalError() logs runtime state (GH-16258)
47bbab9
vstinner commentedon Sep 18, 2019
Ok, I pushed the most important changes that I wanted to push. I close the issue.
vstinner commentedon Oct 8, 2019
New changeset 4d5f94b by Victor Stinner in branch 'master':
bpo-38070: Enhance visit_decref() debug trace (GH-16631)
4d5f94b
vstinner commentedon Oct 15, 2019
New changeset f82ce5b by Victor Stinner in branch '3.8':
[3.8] bpo-36389: Backport debug enhancements from master (GH-16796)
f82ce5b