Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!ames!ucbcad!ucbvax!decvax!tektronix!reed!psu-cs!omepd!mipos3!cpocd2!howard From: howard@cpocd2.UUCP Newsgroups: comp.arch Subject: Re: catering to bad code Message-ID: <436@cpocd2.UUCP> Date: Thu, 19-Feb-87 15:51:44 EST Article-I.D.: cpocd2.436 Posted: Thu Feb 19 15:51:44 1987 Date-Received: Sat, 21-Feb-87 04:29:24 EST References: <14833@amdcad.UUCP> <14837@amdcad.UUCP> Reply-To: howard@cpocd2.UUCP (Howard A. Landman) Distribution: world Organization: Intel Corp. ASIC Services Organization, Chandler AZ Lines: 44 In article <14833@amdcad.UUCP> phil@amdcad.UUCP (Phil Ngai) writes: > In a Unix system I am designing, I am considering catering to bad > code. That is, like the VAX I propose to make location 0 contain a > readable 0. > What do people think of this? Is it kind of disgusting? I agree with Rob and others who have said No (don't do it) and Yes (it's disgusting). It's not just location 0. It's all small integers, positive and negative. I once made a typo which left legal code that managed to pass lint but still dereferenced address 1 (or was it 3?), treating it as a (char *) and printing the string (i.e. the contents of low memory) out onto the users terminal. The terminal was emulating a VT100 and low memory just happened to contain several copies of the "Control String Initiator" character. The result was that the terminal would hang waiting for a "Control String Terminator" that never came. Explaining this bug to customers who had just lost minutes/hours of work was not pleasant. Explaining to management how it had occurred and gotten by me unnoticed AND GOTTEN THROUGH SIX WEEKS OF SOFTWARE QA UNNOTICED *AND* *BEEN* *SHIPPED* *TO* *EVERY* *CUSTOMER* was even less enjoyable. On a machine without read access to page 0 this bug would have caused a simple core dump and been easy to find and fix. Approximately, INTENDED CODE: printf("%s is %d","name",value); ACTUAL CODE: printf("%s is %d",value); (Note: this was before "printfck", which finds this error easily.) It is safer to make page 0 *and* page -1 both inaccessible to catch all uses of small integers as pointers, no matter which sign. And perhaps even all the pages addressable by shorts. Actually, you'd like it to be true that you couldn't accidentally use ANY integer in place of a pointer, but this is not easy on an untagged machine unless you are willing to make most or all of your address space inaccessible. ;-) Perhaps this is an argument for tagged architectures. Use of location 0 is a bug. It is not portable to many machines and operating systems (e.g. VMS). And lots of early UNIX programs do it. :^( -- Howard A. Landman ...!intelca!mipos3!cpocd2!howard