bpo-45061: Detect Py_DECREF(Py_True) bug#28089
Merged
vstinner merged 2 commits intopython:mainfrom Aug 31, 2021
vstinner:bool_dealloc
Merged
bpo-45061: Detect Py_DECREF(Py_True) bug#28089vstinner merged 2 commits intopython:mainfrom vstinner:bool_dealloc
vstinner merged 2 commits intopython:mainfrom
vstinner:bool_dealloc
Conversation
Add a deallocator to the bool type to detect refcount bugs in C extensions which call Py_DECREF(Py_True) or Py_DECREF(Py_False) by mistake.
Member
Author
Member
Author
|
Using os_uname_refcount_bug.patch of bpo-45061, I get the following error message: |
Member
Author
|
It is not possible to create a subclass of bool: |
ambv
reviewed
Aug 31, 2021
Objects/boolobject.c
Outdated
| static void _Py_NO_RETURN | ||
| bool_dealloc(PyObject* Py_UNUSED(ignore)) | ||
| { | ||
| Py_FatalError("deallocating True or False likely caused by refcount bug " |
Contributor
There was a problem hiding this comment.
Suggested change
| Py_FatalError("deallocating True or False likely caused by refcount bug " | |
| Py_FatalError("deallocating True or False likely caused by a refcount bug " |
ambv
reviewed
Aug 31, 2021
Objects/object.c
Outdated
| * we accidentally decref None out of existence. | ||
| */ | ||
| Py_FatalError("deallocating None"); | ||
| Py_FatalError("deallocating None likely caused by refcount bug " |
Contributor
There was a problem hiding this comment.
Suggested change
| Py_FatalError("deallocating None likely caused by refcount bug " | |
| Py_FatalError("deallocating None likely caused by a refcount bug " |
Member
Author
|
@ambv: Sure, I changed the error message. |
Member
Author
|
Merged. Thanks for the reviews! I don't think that it's worth it to backport it to 3.10, it's a new feature. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a deallocator to the bool type to detect refcount bugs in C
extensions which call Py_DECREF(Py_True) or Py_DECREF(Py_False) by
mistake.
https://bugs.python.org/issue45061