New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-45061: Detect Py_DECREF(Py_True) bug #28089
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.
Using os_uname_refcount_bug.patch of bpo-45061, I get the following error message:
|
It is not possible to create a subclass of bool:
|
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 " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Py_FatalError("deallocating True or False likely caused by refcount bug " | |
Py_FatalError("deallocating True or False likely caused by a refcount bug " |
Objects/object.c
Outdated
* we accidentally decref None out of existence. | ||
*/ | ||
Py_FatalError("deallocating None"); | ||
Py_FatalError("deallocating None likely caused by refcount bug " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Py_FatalError("deallocating None likely caused by refcount bug " | |
Py_FatalError("deallocating None likely caused by a refcount bug " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with @ambv's suggestion ;)
@ambv: Sure, I changed the error message. |
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. |
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