[Python-Dev] RE: test_sort.py failure

Armin Rigo arigo at tunes.org
Thu Jul 29 02:20:55 CEST 2004


Hello,

On Wed, Jul 28, 2004 at 05:00:59PM -0700, Guido van Rossum wrote:
> Mucking with the list causes realloc() calls to the memory block
> initially pointed to by empty_ob_item.  This is likely to move the
> block.  But it *could* be that there's enough space following the
> block that it *doesn't* have to be moved, and if the array also
> happens to be empty after the sort (there's a certain probability that
> this is so), the test will pass despite the mucking.

I think Tim is right: the code used to be correct, but the list internals
reorganization might have broken that.  As far as I remember, the reason it
used to be fine is that lists with zero elements were always deallocated, so
that empty lists never had an allocated ob_items array.  If user code
populated and then emptied again the list during the sort, it couldn't end up
again in the special state list_sort() puts it in, which is ob_size == 0 but
ob_items allocated.  Apparently, this can occur now.

Looks like another review of list_sort() is needed.  (Some time ago, after
staring at it for some time, I wondered and couldn't figure out if there was a
memory leak or not, too)


Armin


More information about the Python-Dev mailing list