CompuServe Thread

#Mem. loc. 0? Who Cares?

3 messages in this thread
#114666From: Thomas HoladayJul 27, 1990 12:53 PM
What is it with low memory trashing, anyway? Is location 0 supposed to be 0 all the time as a sanity check of some sort? Is it in the index of the ROM Kernel Manuals? Hey, maybe a "Where in the Operating System is Carmen Sandiega?" would be an educational-fun way to master BPTRs.
#114674From: Mike Spille/ManxJul 27, 1990 1:35 PM
What happens is this: char *foo; main () { if (*foo == 0) do_somethin(); else do_somethin_else(); } In this code, 'foo' is never initialized to point to anything. However, a rule in C is that uninitialized global variables get implicitly initialized to '0' – thus, foo is guaranteed to be a null pointer. Now, the code in main is obviously in error, since foo isn't initialized, but if location 0 always happens to contains a 0, then the code will always take the if branch instead of the else branch, and the developer of the code may say 'yep, that's what's supposed to happen…'. However, all of a sudden you find a machine where location 0 _doesn't_ have a 0 – and poof, your software mysteriously breaks. -Mike
#114699From: Bill HawesJul 27, 1990 6:34 PM
Thomas, Location 0 isn't used for anything and is usually 0, but low-memory trashing is an important indicator of the general quality (lack of quality) of a software package. Consider what happens when you reference something relative to a NULL pointer (perhaps from an undetected memory allocation failure?) -if you're storing into a structure, you write into low memory at the structure offset. If you're reading a value from the structure, you get whatever happened to be in low memory. Good software has generally been extensively tested for thissort of problem and will rarely exhibit a low-memory bug. Software rushed out the door, on the other hand … -Bill