Issue 38070: visit_decref(): add an assertion to check that the object is not freed (original) (raw)

Created on 2019-09-09 14:05 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bpo-38037-bug.patch vstinner,2019-09-09 14:12
Pull Requests
URL Status Linked Edit
PR 15782 merged vstinner,2019-09-09 14:09
PR 15793 merged miss-islington,2019-09-09 15:45
PR 16243 merged vstinner,2019-09-17 21:03
PR 16244 merged vstinner,2019-09-17 21:10
PR 16245 merged vstinner,2019-09-17 21:36
PR 16246 merged vstinner,2019-09-17 22:01
PR 16258 merged vstinner,2019-09-18 09:42
PR 16631 merged vstinner,2019-10-07 23:53
PR 16816 closed vstinner,2019-10-16 01:37
Messages (15)
msg351470 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-09 14:05
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.
msg351473 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-09 14:12
> visit_decref() is commonly found in C traceback (ex: gdb backtrace) of bugs related to the garbage collector. 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.
msg351504 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-09 15:45
New changeset d91d4de31745fc1ed4c7e6c208917827c9c472b6 by Victor Stinner in branch 'master': bpo-38070: visit_decref() calls _PyObject_IsFreed() (GH-15782) https://github.com/python/cpython/commit/d91d4de31745fc1ed4c7e6c208917827c9c472b6
msg351537 - (view) Author: miss-islington (miss-islington) Date: 2019-09-09 17:18
New changeset 5731172bb1e958b1d80b18eaf88d3f2f93cfccdd by Miss Islington (bot) in branch '3.8': bpo-38070: visit_decref() calls _PyObject_IsFreed() (GH-15782) https://github.com/python/cpython/commit/5731172bb1e958b1d80b18eaf88d3f2f93cfccdd
msg351645 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-09-10 13:16
Should this be closed now?
msg351686 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-10 14:48
> Should this be closed now? Please keep it open, I have a few more local changess to enhance Py_FatalError() :-) I would like to reuse the bpo number.
msg352665 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-17 21:36
New changeset 8fa3e1740b3f03ea65ddb68411c2238c5f98eec2 by Victor Stinner in branch 'master': bpo-38070: _Py_DumpTraceback() writes (GH-16244) https://github.com/python/cpython/commit/8fa3e1740b3f03ea65ddb68411c2238c5f98eec2
msg352666 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-17 21:36
New changeset b39afb78768418d9405c4b528c80fa968ccc974d by Victor Stinner in branch 'master': bpo-38070: Enhance _PyObject_Dump() (GH-16243) https://github.com/python/cpython/commit/b39afb78768418d9405c4b528c80fa968ccc974d
msg352667 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-17 21:59
New changeset d3b904144e86e2442961de6a7dccecbe133d5c6d by Victor Stinner in branch 'master': bpo-38070: Add _PyRuntimeState.preinitializing (GH-16245) https://github.com/python/cpython/commit/d3b904144e86e2442961de6a7dccecbe133d5c6d
msg352675 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-17 23:35
New changeset 1ce16fb0977283ae42a9f8917bbca5f44aa69324 by Victor Stinner in branch 'master': bpo-38070: Py_FatalError() logs runtime state (GH-16246) https://github.com/python/cpython/commit/1ce16fb0977283ae42a9f8917bbca5f44aa69324
msg352676 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-17 23:38
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): Aborted (core dumped) --- * Obviously, "Modules/gcmodule.c:379: visit_decref: Assertion "!_PyObject_IsFreed(op)" failed" is the first most visible enhancement * Add "Python runtime state: finalizing (tstate=0x1d1c9b0)": Python is finalizing (Py_Finalize) * New "" in the traceback * "" became "<object at 0x7ff0038956d0 is freed>": add the object address
msg352720 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-18 12:10
New changeset 47bbab9f76735acc1991e541d12fd18be6b13b16 by Victor Stinner in branch '3.8': [3.8] bpo-38070: Py_FatalError() logs runtime state (GH-16258) https://github.com/python/cpython/commit/47bbab9f76735acc1991e541d12fd18be6b13b16
msg352721 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-18 12:10
Ok, I pushed the most important changes that I wanted to push. I close the issue.
msg354156 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-08 00:37
New changeset 4d5f94b8cd20f804c7868c5395a15aa6032f874c by Victor Stinner in branch 'master': bpo-38070: Enhance visit_decref() debug trace (GH-16631) https://github.com/python/cpython/commit/4d5f94b8cd20f804c7868c5395a15aa6032f874c
msg354681 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-15 01:06
New changeset f82ce5b1b12873b65927149a016be6a7c65e979d by Victor Stinner in branch '3.8': [3.8] bpo-36389: Backport debug enhancements from master (GH-16796) https://github.com/python/cpython/commit/f82ce5b1b12873b65927149a016be6a7c65e979d
History
Date User Action Args
2022-04-11 14:59:20 admin set github: 82251
2019-10-16 01:37:51 vstinner set pull_requests: + <pull%5Frequest16368>
2019-10-15 01:06:21 vstinner set messages: +
2019-10-08 00:37:42 vstinner set messages: +
2019-10-07 23:53:15 vstinner set pull_requests: + <pull%5Frequest16217>
2019-09-18 12:10:58 vstinner set status: open -> closedversions: + Python 3.8messages: + resolution: fixedstage: patch review -> resolved
2019-09-18 12:10:33 vstinner set messages: +
2019-09-18 09:42:39 vstinner set pull_requests: + <pull%5Frequest15853>
2019-09-17 23:38:47 vstinner set messages: +
2019-09-17 23:35:36 vstinner set messages: +
2019-09-17 22:01:20 vstinner set pull_requests: + <pull%5Frequest15842>
2019-09-17 21:59:55 vstinner set messages: +
2019-09-17 21:36:55 vstinner set pull_requests: + <pull%5Frequest15841>
2019-09-17 21:36:31 vstinner set messages: +
2019-09-17 21:36:19 vstinner set messages: +
2019-09-17 21:10:37 vstinner set pull_requests: + <pull%5Frequest15840>
2019-09-17 21:03:18 vstinner set pull_requests: + <pull%5Frequest15839>
2019-09-10 14:48:40 vstinner set messages: +
2019-09-10 13:16:49 pablogsal set nosy: + pablogsalmessages: +
2019-09-09 17🔞12 miss-islington set nosy: + miss-islingtonmessages: +
2019-09-09 15:45:12 miss-islington set pull_requests: + <pull%5Frequest15446>
2019-09-09 15:45:02 vstinner set messages: +
2019-09-09 14:12:09 vstinner set files: + bpo-38037-bug.patchmessages: +
2019-09-09 14:09:45 vstinner set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest15435>
2019-09-09 14:05:36 vstinner create