Path: utzoo!attcan!lsuc!eci386!clewis From: clewis@eci386.uucp (Chris Lewis) Newsgroups: comp.unix.wizards Subject: Re: Referencing NULL pointers Message-ID: <1989Jul24.193048.296@eci386.uucp> Date: 24 Jul 89 19:30:48 GMT References: <1989Jul14.092231.24845@inquiry.org> <19367@paris.ics.uci.edu> <10515@smoke.BRL.MIL> <168@jma.UUCP> <1501@ibmpa.UUCP> <12928@bloom-beacon.MIT.EDU> Reply-To: clewis@eci386.UUCP (Chris Lewis) Organization: R. H. Lathwell Associates: Elegant Communications, Inc. Lines: 26 In article <12928@bloom-beacon.MIT.EDU> jik@athena.mit.edu (Jonathan I. Kamens) writes: >We're using something here at Project Athena which the compiler gurus >call "Z0MAGIC" > >What it does is, if the -Z flag is specified to the linker, cause any >executing program to unmap page zero so that dereferencing null >pointers will always cause a segfault. Many moons ago, (Hi Dennis!), one of the development groups I worked with wrote a sed script to parse assembler output from the C compiler, and when it detected indirections, inserted a sequence of instructions before the reference to check the pointer for null and abort. Then wrote a shell script around it that would "cc -S", sed, and then assemble (analogous to "cc -c" with an extra step). This was on a VAX, running BSD4.1. This was a pretty gruesome hack, so gruesome that I never bothered to look at the fine details. They figured, so what if it ran slow - it was only used to run debug versions (the target trapped null dereferences by not mapping location 0). This idea might be useful to those not having kernel source. -- Chris Lewis, R.H. Lathwell & Associates: Elegant Communications Inc. UUCP: {uunet!mnetor, utcsri!utzoo}!lsuc!eci386!clewis Phone: (416)-595-5425