This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients davin, larry, serhiy.storchaka, vstinner
Date 2017-10-26.14:35:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The current code OBVIOUSLY is wrong. Bytes are erased if q == oldq && nbytes < original_nbytes. But q == oldq only if realloc() returns the new address 2*sizeof(size_t) bytes larger than its argument. This is virtually never happen on other platforms because _PyMem_DebugRawRealloc() usually used with blocks larger than 2*sizeof(size_t) bytes and the system realloc() don't shrink the block at left (this is implementation detail). Thus this code is virtually dead on other platforms. It doesn't detect shrinking memory block in-place.

After fixing *this* bug, we have encountered with *other* bug, related to overwriting the freed memory.

I don't see reasons of keeping an obviously wrong code. When fix the first bug we will need to fix the other bug.
Date User Action Args
2017-10-26 14:35:15serhiy.storchakasetrecipients: + serhiy.storchaka, vstinner, larry, davin
2017-10-26 14:35:15serhiy.storchakasetmessageid: <>
2017-10-26 14:35:15serhiy.storchakalinkissue31626 messages
2017-10-26 14:35:15serhiy.storchakacreate