[Python-Dev] Enhancement of Python memory allocators

Nick Coghlan ncoghlan at gmail.com
Thu Jun 13 04:40:35 CEST 2013


On 13 Jun 2013 10:09, "Victor Stinner" <victor.stinner at gmail.com> wrote:
>
> 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.

Yes, that sounds better. One of the biggest problems with the current
startup sequence is the way it relies on environment variables for
configuration, which makes life hard for other applications that want to
embed the CPython runtime.

Cheers,
Nick.

>
> Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130613/4cd7580f/attachment.html>


More information about the Python-Dev mailing list