bpo-36389: _PyObject_CheckConsistency() now also works in release mode by vstinner · Pull Request #16612 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation5 Commits1 Checks0 Files changed

Conversation

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

[ Show hidden characters]({{ revealButtonHref }})

vstinner

bpo-36389, bpo-38376: Modify the following functions to also work in
release mode:

The main function _PyObject_CheckConsistency() can be used for
debugging purpose, like crash in visit_decref() of the GC.

_PyBytesWriter_CheckConsistency() now returns 1 and is only used with
assert().

https://bugs.python.org/issue36389

@vstinner

Yhg1s

@Yhg1s

Roping in the 3.8 release manager for the question of whether this should go into 3.8.0.

@vstinner

This change mostly impacts the debugging experience. It doesn't change Python in release mode: modified functions only becomes available in release mode, but are never called.

@Yhg1s: Thanks for your review. I agree that "define ASSERT" is confusing. I renamed my macros to "CHECK" as you suggested.

I also included other fixes for these debug functions.

@vstinner

bpo-36389, bpo-38376: The _PyObject_CheckConsistency() function is now also available in release mode. For example, it can be used to debug a crash in the visit_decref() function of the GC.

Modify the following functions to also work in release mode:

Other changes:

@vstinner

@vstinner vstinner removed the needs backport to 3.8 label now

I wrote a minimum fix for 3.8: PR #16623.

I may backport this change to 3.8, but only after the final 3.8.0 release. We can discuss that later ;-)

vstinner added a commit that referenced this pull request

Oct 15, 2019

@vstinner

bpo-36389, bpo-38376: The _PyObject_CheckConsistency() function is now also available in release mode. For example, it can be used to debug a crash in the visit_decref() function of the GC.

Modify the following functions to also work in release mode:

Other changes:

(cherry picked from commit 6876257)

Fix _PyBytesWriter API when Python is built in release mode with assertions.

(cherry picked from commit 60ec6ef)

subtract_refs() now pass the parent object to visit_decref() which pass it to _PyObject_ASSERT(). So if the "is freed" assertion fails, the parent is used in debug trace, rather than the freed object. The parent object is more likely to contain useful information. Freed objects cannot be inspected are are displayed as "" with no other detail.

(cherry picked from commit 4d5f94b)

Add a newline between the verbose object dump and the Py_FatalError() logs for readability.

(cherry picked from commit 7775349)

jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request

Dec 5, 2019

@vstinner

…thonGH-16612)

bpo-36389, bpo-38376: The _PyObject_CheckConsistency() function is now also available in release mode. For example, it can be used to debug a crash in the visit_decref() function of the GC.

Modify the following functions to also work in release mode:

Other changes: