Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.50 diff -c -r2.50 obmalloc.c *** obmalloc.c 23 Nov 2002 09:13:40 -0000 2.50 --- obmalloc.c 3 Apr 2003 03:00:48 -0000 *************** *** 1124,1129 **** --- 1124,1130 ---- { const uchar *q = (const uchar *)p; const uchar *tail; + int tail_reachable = 0; /* can we dereference tail without segfault */ ulong nbytes, serial; int i; *************** *** 1161,1188 **** tail = q + nbytes; fprintf(stderr, " The 4 pad bytes at tail=%p are ", tail); ! if (tail[0] == FORBIDDENBYTE && ! tail[1] == FORBIDDENBYTE && ! tail[2] == FORBIDDENBYTE && ! tail[3] == FORBIDDENBYTE) { ! fputs("FORBIDDENBYTE, as expected.\n", stderr); } ! else { ! fprintf(stderr, "not all FORBIDDENBYTE (0x%02x):\n", ! FORBIDDENBYTE); ! for (i = 0; i < 4; ++i) { ! const uchar byte = tail[i]; ! fprintf(stderr, " at tail+%d: 0x%02x", ! i, byte); ! if (byte != FORBIDDENBYTE) ! fputs(" *** OUCH", stderr); ! fputc('\n', stderr); } - } ! serial = read4(tail+4); ! fprintf(stderr, " The block was made by call #%lu to " ! "debug malloc/realloc.\n", serial); if (nbytes > 0) { int i = 0; --- 1162,1202 ---- tail = q + nbytes; fprintf(stderr, " The 4 pad bytes at tail=%p are ", tail); ! #ifdef MS_WINDOWS ! _try { ! #endif /* MS_WINDOWS */ ! tail_reachable = *tail ? 1 : 1; /* if we don't die, it is reachable! */ ! #ifdef MS_WINDOWS ! } _except(1) { ! /* tail_reachable remains 0 */ } ! #endif /* MS_WINDOWS */ ! if (tail_reachable) { ! if (tail[0] == FORBIDDENBYTE && ! tail[1] == FORBIDDENBYTE && ! tail[2] == FORBIDDENBYTE && ! tail[3] == FORBIDDENBYTE) { ! fputs("FORBIDDENBYTE, as expected.\n", stderr); ! } ! else { ! fprintf(stderr, "not all FORBIDDENBYTE (0x%02x):\n", ! FORBIDDENBYTE); ! for (i = 0; i < 4; ++i) { ! const uchar byte = tail[i]; ! fprintf(stderr, " at tail+%d: 0x%02x", ! i, byte); ! if (byte != FORBIDDENBYTE) ! fputs(" *** OUCH", stderr); ! fputc('\n', stderr); ! } } ! serial = read4(tail+4); ! fprintf(stderr, " The block was made by call #%lu to " ! "debug malloc/realloc.\n", serial); ! } else { ! fprintf(stderr, "INVALID\n"); ! } if (nbytes > 0) { int i = 0; *************** *** 1194,1200 **** ++q; } /* and up to 8 at the end */ ! if (q < tail) { if (tail - q > 8) { fputs(" ...", stderr); q = tail - 8; --- 1208,1214 ---- ++q; } /* and up to 8 at the end */ ! if (q < tail && tail_reachable) { if (tail - q > 8) { fputs(" ...", stderr); q = tail - 8;