[issue40928] OS X: malloc(): set default diagnostics to DEBUG_WRITE_ON_CRASH

STINNER Victor report at bugs.python.org
Wed Jun 10 09:40:53 EDT 2020


STINNER Victor <vstinner at python.org> added the comment:

> Would it be possible to wrap malloc_print_configure() (https://github.com/PureDarwin/libmalloc/blob/e37056265821cd6e014ab911d9fe3b9d0da88e22/src/malloc_printf.c#L59) in a context manager that we put in test.support? or to override https://github.com/PureDarwin/libmalloc/blob/e37056265821cd6e014ab911d9fe3b9d0da88e22/src/malloc_printf.c#L36?

I don't see much benefit of having a feature which only works on macOS.

You can put a hook on memory allocations using PyMem_SetAllocator() to trigger any action you want when any memory allocation done by Python fails.

But is it really an use case to log any memory allocation failure? Python is very likely to raise a MemoryError exception in this case. It's well defined, no?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40928>
_______________________________________


More information about the Python-bugs-list mailing list