GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-101430: Update tracemalloc to handle presize properly. by corona10 · Pull Request #101745 · python/cpython Conversation
|
AS-ISTO-BE |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I now read all the spec of the preheader from #29879. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@colesbury PTAL |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| type = Py_TYPE(obj); | ||
| if (PyType_IS_GC(type)) { | ||
| ptr = (void *)((char *)obj - sizeof(PyGC_Head)); | ||
| const size_t presize = _PyType_PreHeaderSize(type); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This looks correct, but I think it would be more straightforward if you skip the PyType_IS_GC check (and always subtract the pre-header size.) _PyType_PreHeaderSize returns zero for non-GC types.
For context, here's an example in _PyType_AllocNoTrack that operates on GC and non-GC types and unconditionally adds the pre-header size:
Lines 1300 to 1301 in ecfd2d3
| const size_t presize = _PyType_PreHeaderSize(type); | |
| char *alloc = PyObject_Malloc(size + presize); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@corona10 There's also one more tracemalloc related use of Lines 2390 to 2398 in ecfd2d3
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thank you for catching all of them! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I believe this is good, but I've looped in @vstinner for an extra pair of expert eyes on this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
AFAIK, Victor is enjoying his detoxing for OSS. cc @vstinner |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* main: Fix some typos in asdl_c.py (pythonGH-101757) pythongh-101747: Fix refleak in new `OrderedDict` repr (pythonGH-101748) pythongh-101430: Update tracemalloc to handle presize properly. (pythongh-101745) pythonGH-101228: Fix typo in docstring for read method of `_io.TextIOWrapper` class (python#101227) Fix typo in `test_fstring.py` (python#101600) pythongh-101726: Update the OpenSSL version to 1.1.1t (pythonGH-101727) pythongh-101283: Fix 'versionchanged' for the shell=True fallback on Windows in 3.12 (pythonGH-101728) LibFFI build requires x64 Cygwin, and skip the ARM build (pythonGH-101743)
|
Thanks for this nice fix @corona10! _PyType_PreHeaderSize() is convenient and better than previously copied-pasted code ;-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.