[Python-Dev] tests failing in 2.2.2
Guido van Rossum
guido@python.org
Tue, 08 Oct 2002 16:25:06 -0400
> [Guido, on the list(xrange(maxint // 4)) test]
> > That's strange -- that test is specifically designed to fail before it
> > ever gets to allocating memory. Can you track this down with a
> > debugger?
>
> [Martin]
> > Notice that this test does not strictly achieve that:
[Tim]
> This is true, although I'd say it plain doesn't achieve that, and leave
> "strictly" out of it.
>
> > with a four-byte pointer, you attempt to allocate 0x20000000L items (due
> > to roundupsize), which is small enough to try a realloc. In turn, it
> > tries to allocate 0x80000000L bytes, i.e. 2GB. On a 32-bit machine, it
> > is possible to allocate that much memory.
>
> Depending on platform, of course. Under MSVC6, it does call the platform
> realloc(), and it's the latter that returns a NULL pointer (the max you can
> alloc under Win32 is 0x7ffdefff).
>
> If we changed the test to use maxint // 2 instead, it would (just barely)
> trigger the
>
> _new_size <= ((~(size_t)0) / sizeof(type))
>
> test in NRESIZE instead, and keep the platform realloc() out of it.
>
> Good enough?
[Guido] I'd say so, except I fear that it might cause different
problems (not that I know of any). I tried it on Linux and on Win98
and it works fine. I presume you've tested it on Win2K.
But wasn't it specifically designed to catch a condition that was only
true when the size was (approximately) maxint/4?
--Guido van Rossum (home page: http://www.python.org/~guido/)