Issue 33622: Fix and improve errors handling in the garbage collector (original) (raw)

Issue33622

Created on 2018-05-23 17:41 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7078 merged serhiy.storchaka,2018-05-23 17:50
PR 7094 merged miss-islington,2018-05-24 12:19
PR 7095 merged serhiy.storchaka,2018-05-24 12:30
PR 7096 merged serhiy.storchaka,2018-05-24 12:30
PR 7126 merged serhiy.storchaka,2018-05-26 10:07
Messages (8)
msg317431 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-23 17:41
There are following bugs in the garbage collector. * If the garbage collector fails to add an object with __del__ or referenced by an object with __del__ to gc.garbage (in handle_legacy_finalizers()), it leaks it and other not added objects with __del__ and referenced by them. They become no longer accessible by the garbage collector. * PyGC_Collect() is not documented, but it is a public C API. And it can be called by user with an exception set. PyGC_Collect() then can either crash or just silent the exception. It is safer to safe possible exception and restore it after collecting. * A pointer to released member can be used (compared with NULL) in invoke_gc_callback(). This is an undefined behavior.
msg317567 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-24 12:19
New changeset 301e3cc8a5bc68c5347ab6ac6f83428000d31ab2 by Serhiy Storchaka in branch 'master': bpo-33622: Fix issues with handling errors in the GC. (GH-7078) https://github.com/python/cpython/commit/301e3cc8a5bc68c5347ab6ac6f83428000d31ab2
msg317568 - (view) Author: miss-islington (miss-islington) Date: 2018-05-24 12:39
New changeset 2fe940c727802ad54cff9486c658bc38743f7bfc by Miss Islington (bot) in branch '3.7': bpo-33622: Fix issues with handling errors in the GC. (GH-7078) https://github.com/python/cpython/commit/2fe940c727802ad54cff9486c658bc38743f7bfc
msg317569 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-24 13:05
New changeset f0e04b2ae27a4da940a76ae522f0438f80ce5d5a by Serhiy Storchaka in branch '3.6': [3.6] bpo-33622: Fix issues with handling errors in the GC. (GH-7078) (GH-7095) https://github.com/python/cpython/commit/f0e04b2ae27a4da940a76ae522f0438f80ce5d5a
msg317617 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-24 20:27
New changeset 9044cd675902b438bc500908e410382ff48299d8 by Serhiy Storchaka in branch '2.7': [2.7] bpo-33622: Fix issues with handling errors in the GC. (GH-7078) (#7096) https://github.com/python/cpython/commit/9044cd675902b438bc500908e410382ff48299d8
msg317732 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-26 10:13
PR 7126 adds several assert(!PyErr_Occurred()) for earlier detection of leaked exceptions. And the failure in adding to gc.garbage is no longer fatal. It is better to not add an object to gc.garbage in this iteration than crash when we run garbage collection when have no memory.
msg318048 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-29 15:50
New changeset c4653c9bf159c3919a50f4ced32eef713e7e764e by Serhiy Storchaka in branch 'master': bpo-33622: Add checks for exceptions leaks in the garbage collector. (GH-7126) https://github.com/python/cpython/commit/c4653c9bf159c3919a50f4ced32eef713e7e764e
msg318290 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-31 12:30
See , and for three cases in the stdlib where an exception can be set in the tp_clear handler. This caused a crash in the garbage collector, or can be just silenced if failed at the shutdown stage. In the master branch it will cause writing a traceback to the stderr. It would be better to handle exceptions locally in the tp_clear handlers. But perhaps it may be worth to handle leaked exceptions in the garbage collector too. I'm just not sure about a solution. Writing a traceback to the stderr can cause a regression if it was just silenced before. But silencing it can hide bugs.
History
Date User Action Args
2022-04-11 14:59:00 admin set github: 77803
2019-03-21 13:09:05 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2018-05-31 12:30:05 serhiy.storchaka set messages: +
2018-05-29 15:50:13 serhiy.storchaka set messages: +
2018-05-26 10:13:29 serhiy.storchaka set messages: +
2018-05-26 10:07:43 serhiy.storchaka set stage: patch reviewpull_requests: + <pull%5Frequest6761>
2018-05-26 10:02:57 serhiy.storchaka set status: closed -> opentitle: Fix errors handling in the garbage collector -> Fix and improve errors handling in the garbage collectorresolution: fixed -> (no value)stage: resolved -> (no value)
2018-05-25 14:14:35 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2018-05-24 20:27:11 serhiy.storchaka set messages: +
2018-05-24 13:05:43 serhiy.storchaka set messages: +
2018-05-24 12:39:11 miss-islington set nosy: + miss-islingtonmessages: +
2018-05-24 12:30:35 serhiy.storchaka set pull_requests: + <pull%5Frequest6732>
2018-05-24 12:30:23 serhiy.storchaka set pull_requests: + <pull%5Frequest6731>
2018-05-24 12:19:45 miss-islington set pull_requests: + <pull%5Frequest6730>
2018-05-24 12:19:37 serhiy.storchaka set messages: +
2018-05-24 08:05:16 pitrou set priority: normal -> low
2018-05-23 18:04:41 serhiy.storchaka set title: Fix and improve errors handling in the garbage collector -> Fix errors handling in the garbage collector
2018-05-23 17:50:39 serhiy.storchaka set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest6708>
2018-05-23 17:41:20 serhiy.storchaka create