[Python-Dev] [Python-checkins] commit of r41906 - python/branches/ssize_t/Objects/obmalloc.c (original) (raw)
Tim Peters tim.peters at gmail.com
Tue Jan 3 19:38:03 CET 2006
- Previous message: [Python-Dev] API changes
- Next message: [Python-Dev] [Python-checkins] commit of r41906 - python/branches/ssize_t/Objects/obmalloc.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: martin.v.loewis Date: Tue Jan 3 14:16:53 2006 New Revision: 41906
Modified: python/branches/ssizet/Objects/obmalloc.c Log: Disable 32-bit size limitation for 64-bit mode.
Modified: python/branches/ssizet/Objects/obmalloc.c ============================================================================== --- python/branches/ssizet/Objects/obmalloc.c (original) +++ python/branches/ssizet/Objects/obmalloc.c Tue Jan 3 14:16:53 2006 @@ -1005,6 +1005,8 @@ bumpserialno(); total = nbytes + 16; +#if SIZEOFSIZET < 8_ _+ /* XXX do this check only on 32-bit machines */_ _if (total < nbytes || (total >> 31) > 1) { /* overflow, or we can't represent it in 4 bytes */ /* Obscure: can't do (total >> 32) != 0 instead, because @@ -1013,6 +1015,7 @@ sizet is an unsigned type. */ return NULL; } +#endif
This checkin should be reverted for now. It's in _PyObject_DebugMalloc, and at present the layout of the extra debug info in a PYMALLOC_DEBUG build is hard-coded to use 4-byte fields, no matter what sizeof(size_t) may be. One of the extra fields recorded in a PYMALLOC_DEBUG build is the number of bytes requested, and at present it's simply not capable of recording a value that doesn't fit in 4 bytes.
Even after (if ever ;-)) this is changed to support recording 8-byte
values on a box where sizeof(size_t) == 8, the "total < nbytes" part
of the test would still be appropriate: PyObject_DebugMalloc requests
more memory (total
) than the user asked for (nbytes
), and the
computation of total
may have overflowed. That's what "total <
nbytes" is checking, and that's the right way to spell the overflow
check on any box.
- Previous message: [Python-Dev] API changes
- Next message: [Python-Dev] [Python-checkins] commit of r41906 - python/branches/ssize_t/Objects/obmalloc.c
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]