[Patches] [ python-Patches-714348 ] Guard against segfaults in debug code

SourceForge.net noreply@sourceforge.net
Wed, 02 Apr 2003 19:16:30 -0800


Patches item #714348, was opened at 2003-04-03 13:14
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=714348&group_id=5470

Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Mark Hammond (mhammond)
Assigned to: Tim Peters (tim_one)
Summary: Guard against segfaults in debug code

Initial Comment:
When dumping invalid objects, we may as well avoid
segfaults if possible.  This allows us to extract as
much information as possible before dieing, which may
be handy in release builds etc.

Trivial patch just to get started (as I actually hit
this block!).  Assign back if you are OK with it, or I
will be OK with you not wanting to start this slippery
slope.

----------------------------------------------------------------------

>Comment By: Mark Hammond (mhammond)
Date: 2003-04-03 13:16

Message:
Logged In: YES 
user_id=14198

Attaching patch.  It indents a couple of blocks, so FYI, a
--ignore-all-space diff is:

RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v
retrieving revision 2.50
diff -w -r2.50 obmalloc.c
1126a1127
>       int tail_reachable = 0; /* can we dereference tail
without segfault */
1163a1165,1175
> #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) {
1185a1198,1200
>       } else {
>               fprintf(stderr, "INVALID\n");
>       }
1197c1212
<               if (q < tail) {
---
>               if (q < tail && tail_reachable) {

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=714348&group_id=5470