bpo-31626: Fix _PyMem_DebugRawRealloc() on OpenBSD#4119
Closed
vstinner wants to merge 1 commit intopython:masterfrom
vstinner:debug_realloc
Closed
bpo-31626: Fix _PyMem_DebugRawRealloc() on OpenBSD#4119vstinner wants to merge 1 commit intopython:masterfrom vstinner:debug_realloc
vstinner wants to merge 1 commit intopython:masterfrom
vstinner:debug_realloc
Conversation
Fix memory debug hooks on OpenBSD: fix _PyMem_DebugRawRealloc(). Previously, the old resized memory block was modified after realloc() success to fill now unused bytes with the DEADBYTE pattern. On OpenBSD, modifying the old memory block causes a fatal error. On OpenBSD, the function now erases the bytes *before* calling realloc(), but keep a copy of erased bytes to restore them if realloc() fails. The behaviour on other platforms is unchanged: erased bytes *after* realloc() success. Co-Authored-By: Serhiy Storchaka <[email protected]>
vstinner
commented
Oct 25, 2017
| memory block on realloc() success: the program is killed by a fatal | ||
| trap signal. So erase bytes before, but keep a copy to restore erased | ||
| bytes if realloc() fails. */ | ||
| # define REALLOC_WRITE_BEFORE |
Member
Author
There was a problem hiding this comment.
Maybe it would be simpler to modify _PyMem_DebugRawRealloc() to behave "correctly" on all platforms. What do you think?
I don't think that the "copy" memory allocation is a real blocker issue. It's a debug hook, I consider that the memory usage is not a big deal here.
Member
Author
|
@serhiy-storchaka merged a simpler fix: PR #3844. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix memory debug hooks on OpenBSD: fix _PyMem_DebugRawRealloc().
Previously, the old resized memory block was modified after realloc()
success to fill now unused bytes with the DEADBYTE pattern. On
OpenBSD, modifying the old memory block causes a fatal error.
On OpenBSD, the function now erases the bytes before calling
realloc(), but keep a copy of erased bytes to restore them if
realloc() fails.
The behaviour on other platforms is unchanged: erased bytes after
realloc() success.
Co-Authored-By: Serhiy Storchaka [email protected]
https://bugs.python.org/issue31626