cpython/Objects
Tim Peters ddea208be9 Give Python a debug-mode pymalloc, much as sketched on Python-Dev.
When WITH_PYMALLOC is defined, define PYMALLOC_DEBUG to enable the debug
allocator.  This can be done independent of build type (release or debug).
A debug build automatically defines PYMALLOC_DEBUG when pymalloc is
enabled.  It's a detected error to define PYMALLOC_DEBUG when pymalloc
isn't enabled.

Two debugging entry points defined only under PYMALLOC_DEBUG:

+ _PyMalloc_DebugCheckAddress(const void *p) can be used (e.g., from gdb)
  to sanity-check a memory block obtained from pymalloc.  It sprays
  info to stderr (see next) and dies via Py_FatalError if the block is
  detectably damaged.

+ _PyMalloc_DebugDumpAddress(const void *p) can be used to spray info
  about a debug memory block to stderr.

A tiny start at implementing "API family" checks isn't good for
anything yet.

_PyMalloc_DebugRealloc() has been optimized to do little when the new
size is <= old size.  However, if the new size is larger, it really
can't call the underlying realloc() routine without either violating its
contract, or knowing something non-trivial about how the underlying
realloc() works.  A memcpy is always done in this case.

This was a disaster for (and only) one of the std tests:  test_bufio
creates single text file lines up to a million characters long.  On
Windows, fileobject.c's get_line() uses the horridly funky
getline_via_fgets(), which keeps growing and growing a string object
hoping to find a newline.  It grew the string object 1000 bytes each
time, so for a million-character string it took approximately forever
(I gave up after a few minutes).

So, also:

fileobject.c, getline_via_fgets():  When a single line is outrageously
long, grow the string object at a mildly exponential rate, instead of
just 1000 bytes at a time.

That's enough so that a debug-build test_bufio finishes in about 5 seconds
on my Win98SE box.  I'm curious to try this on Win2K, because it has very
different memory behavior than Win9X, and test_bufio always took a factor
of 10 longer to complete on Win2K.  It *could* be that the endless
reallocs were simply killing it on Win2K even in the release build.
2002-03-23 10:03:50 +00:00
..
.cvsignore Ignore a bunch of generated files. 2000-05-02 18:34:30 +00:00
abstract.c Fix leak of NotImplemented in previous checkin to PyNumber_Add(). 2002-03-08 21:28:54 +00:00
bufferobject.c Fix for Bug #216405: 2001-10-19 13:49:35 +00:00
cellobject.c Use new GC API. 2001-08-29 23:54:21 +00:00
classobject.c Be smarter about clearing the weakref lists for instances, instance methods, 2001-10-26 17:56:51 +00:00
cobject.c REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00
complexobject.c SF bug 533198: Complex power underflow raises exception. 2002-03-22 02:48:46 +00:00
descrobject.c SF bug #493561: incorrect format string descrobject.c (Neal Norwitz) 2001-12-15 05:00:30 +00:00
dictobject.c Use pymalloc if it's enabled. 2002-03-22 15:33:15 +00:00
fileobject.c Give Python a debug-mode pymalloc, much as sketched on Python-Dev. 2002-03-23 10:03:50 +00:00
floatobject.c SF bug 525705: [2.2] underflow raise OverflowException. 2002-03-09 04:58:24 +00:00
frameobject.c Fix memory leak in dict_to_map(), SF bug [ #485152 ] memory leak in test_scope. 2001-12-06 15:48:16 +00:00
funcobject.c Fix for SF bug 528132 (Armin Rigo): classmethod().__get__() segfault 2002-03-18 03:09:06 +00:00
intobject.c Bugfix candidate. 2002-02-01 15:34:10 +00:00
iterobject.c Re-enable GC of iter objects. 2002-03-18 20:43:51 +00:00
listobject.c Fix of SF bug #475877 (Mutable subtype instances are hashable). 2001-12-03 16:32:18 +00:00
longobject.c Patch #494047: removes 64-bit ?: to cope on plan9. 2002-03-09 12:02:59 +00:00
methodobject.c Re-enable GC of method objects. 2002-03-18 20:44:53 +00:00
moduleobject.c Fix for SF bug #529050 - ModuleType.__new__ crash. 2002-03-12 20:37:02 +00:00
object.c Build obmalloc.c directly instead of #include'ing from object.c. 2002-03-23 00:20:15 +00:00
obmalloc.c Give Python a debug-mode pymalloc, much as sketched on Python-Dev. 2002-03-23 10:03:50 +00:00
rangeobject.c Use pymalloc if it's enabled. 2002-03-22 15:33:15 +00:00
sliceobject.c Use pymalloc if it's enabled. 2002-03-22 15:33:15 +00:00
stringobject.c Use pymalloc if it's enabled. 2002-03-22 15:33:15 +00:00
structseq.c Use pymalloc if it's enabled. 2002-03-22 15:33:15 +00:00
tupleobject.c _PyTuple_Resize(): this dumped core on tuple(globals()) for me. Turns 2001-12-07 20:00:04 +00:00
typeobject.c SF patch 530070: pydoc regression, from Martin and Guido. 2002-03-17 18:56:20 +00:00
unicodectype.c removed "register const" from scalar arguments to the unicode 2001-06-27 22:08:26 +00:00
unicodeobject.c Use pymalloc if it's enabled. 2002-03-22 15:33:15 +00:00
unicodetype_db.h forgot to check in the new makeunicodedata.py script 2001-01-21 17:01:31 +00:00
weakrefobject.c proxy_compare(): Make sure that we unwrap both objects being compared if 2001-12-19 16:44:30 +00:00
xxobject.c REMOVED all CWI, CNRI and BeOpen copyright markings. 2000-09-01 23:29:29 +00:00