Issue 714348: Guard against segfaults in debug code (original) (raw)

Created on 2003-04-03 03:14 by mhammond, last changed 2022-04-10 16:08 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
obmalloc.patch mhammond,2003-04-03 03:16 Patch using _try etc on Windows
Messages (4)
msg43271 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2003-04-03 03:14
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.
msg43272 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2003-04-03 03:16
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) {
msg43273 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-04-07 21:44
Logged In: YES user_id=31435 Do you think this helps? I'm OK with it either way. Normally, this routine doesn't exist in a release build, and in the debug build if we didn't segfault we'd end up calling Py_FatalError() after it returned. BTW. since we're on Windows, would it be simpler to call the Win32 IsBadReadPtr()?
msg43274 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2003-04-19 00:22
Logged In: YES user_id=14198 Yeah, it is kinda pointless I agree :)
History
Date User Action Args
2022-04-10 16:08:01 admin set github: 38257
2003-04-03 03:14:16 mhammond create