[Python-Dev] Enhancement of Python memory allocators
Victor Stinner
victor.stinner at gmail.com
Thu Jun 13 02:09:18 CEST 2013
2013/6/13 Nick Coghlan <ncoghlan at gmail.com>:
> On 13 Jun 2013 09:09, "Victor Stinner" <victor.stinner at gmail.com> wrote:
>> Using this patch, detecting memory corruptions (buffer underflow and
>> overflow) can be done without recompilation. We may add an environment
>> variable to enable Python debug functions at runtime, example:
>> PYDEBUGMALLOC=1. There is just a restriction: the environment variable
>> would not be ignored with -E command line option, because command line
>> options are parsed after the first memory allocation. What do you
>> think?
>
> The rest of it sounds fine, but please don't add the runtime switching
> support to our existing main function. Interpreter startup is a mess
> already. If you were interested in helping directly with PEP 432, though,
> that would be good - I haven't been able to spend much time on it lately.
I proposed an environment variable to solve the following issue: when
memory allocators are replaced with custom allocators, debug hooks
cannot be used. Debug hooks must be set before the first memory
allocation.
Another option is to add a new function (ex: PyMem_SetDebugHook()) to
install explicitly debug hooks, so it can be called after
PyMem_SetAllocators() and before the first memory allocation.
Victor
More information about the Python-Dev
mailing list