Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!uw-june!uw-entropy!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c Subject: Re: C run-time checking Message-ID: <1508@dataio.Data-IO.COM> Date: 16 Mar 88 19:32:34 GMT References: <763@uvm-gen.UUCP> Reply-To: bright@dataio.UUCP (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 15 Keywords: C arrays pointers run-time-checking In article <763@uvm-gen.UUCP> hartley@uvm-gen.UUCP (Stephen J. Hartley) writes: >Are there C compilers provided by any >vendors that generate code to perform run-time checking (toggled >by an option on the command line, say)? All 8086 compilers have a compile-time option to insert code that checks for stack overflow. The lack of CPU hardware to check for this is a MAJOR BOTCH! A lot of effort is expended in this direction, and even then it is not 100% reliable (what if an interrupt occurs...). My run-time libraries not only check if the stack pointer is past the end of the stack, but also a 'sentinal' is checked. The sentinal is a word of a known value that is inserted at the end of the stack. If the stack overflows, probabilities are that this word will get trashed. Thus you can check to see if the stack overflowed sometime in the past.