[Python-Dev] Debug entry points for PyMalloc (original) (raw)
Aahz aahz@pythoncraft.com
Sat, 23 Mar 2002 16:05:45 -0500
- Previous message: [Python-Dev] Debug entry points for PyMalloc
- Next message: [Python-Dev] Debug entry points for PyMalloc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Mar 21, 2002, Tim Peters wrote:
+ Define three special bit patterns. In hex, they all end with B (for deBug ), and begin with a vaguely mnemonic letter. Strings of these are unlikely to be legit memory addresses, ints, 7-bit ASCII, or floats: #define PYMALLOCCLEANBYTE 0xCB /* uninitialized memory */ #define PYMALLOCDEADBYTE 0xDB /* free()ed memory */ #define PYMALLOCFORBIDDENBYTE 0xFB /* unusable memory */ The debug malloc/free/realloc use these as follows. Note that this stuff is done regardless of whether PyMalloc handles the request directly or passes it on to the platform malloc (in fact, the debug entry points won't know and won't care). + The Debug malloc asks for 16 extra bytes and fills them with useful stuff:
I'm almost certainly betraying my ignorance here, but it sounds to me like malloc isn't doing any sanity checking to make sure that the memory it received isn't already being used. Should each PyDebugMalloc() walk through the list of used memory?
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"We should forget about small efficiencies, about 97% of the time. Premature optimization is the root of all evil." --Knuth
- Previous message: [Python-Dev] Debug entry points for PyMalloc
- Next message: [Python-Dev] Debug entry points for PyMalloc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]