[3.7] bpo-9263: _PyObject_Dump() detects freed memory (GH-10061) by vstinner · Pull Request #10662 · 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

Conversation3 Commits2 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

@vstinner

_PyObject_Dump() now uses an heuristic to check if the object memory has been freed: log "" in that case.

The heuristic rely on the debug hooks on Python memory allocators which fills the memory with DEADBYTE (0xDB) when memory is deallocated. Use PYTHONMALLOC=debug to always enable these debug hooks.

(cherry picked from commit 82af0b6)

@vstinner

If _PyObject_Dump() detects that the object is freed, don't try to dump it (exit immediately).

Enhance also _PyObject_IsFreed(): it now detects if the pointer itself looks like freed memory.

(cherry picked from commit 2cf5d32)

@miss-islington

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@miss-islington

Sorry, @vstinner, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 95036ea25d47f0081bda2ba96ea327f3375cb6a4 3.6

@bedevere-bot

vstinner added a commit that referenced this pull request

Nov 22, 2018

@vstinner

…GH-10663)

_PyObject_Dump() now uses an heuristic to check if the object memory has been freed: log "" in that case.

The heuristic rely on the debug hooks on Python memory allocators which fills the memory with DEADBYTE (0xDB) when memory is deallocated. Use PYTHONMALLOC=debug to always enable these debug hooks.

(cherry picked from commit 82af0b6)

If _PyObject_Dump() detects that the object is freed, don't try to dump it (exit immediately).

Enhance also _PyObject_IsFreed(): it now detects if the pointer itself looks like freed memory.

(cherry picked from commit 2cf5d32) (cherry picked from commit 95036ea)