home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!corax.udac.uu.se!frej.teknikum.uu.se!flax
- From: flax@frej.teknikum.uu.se (Jonas Flygare)
- Newsgroups: alt.folklore.computers
- Subject: Re: Computer Superstition
- Date: 18 Nov 1992 11:52:05 GMT
- Organization: Dept. of Control and Systems, Teknikum, Uppsala
- Lines: 39
- Distribution: world
- Message-ID: <1992Nov18.124517@frej.teknikum.uu.se>
- References: <10292323.7317.11306@kcbbs.gen.nz>
- Reply-To: flax@mizar.docs.uu.se
- NNTP-Posting-Host: frej.teknikum.uu.se
-
- In article <10292323.7317.11306@kcbbs.gen.nz>, Murray_Moffatt@kcbbs.gen.nz (Murray Moffatt) writes:
- |> We've all heard of common superstitions such as not walking under ladders
- |> and throwing salt over your left shoulder if you spill some, but are
- |> there any superstitions to do with computers?
- |>
- Er, well, yes.. We no longer use Apollo around here, but there was a known
- bug with the 'system' library call. Under certain circumstances it
- thrashed the stack, including the return address.
- Easy fix to this was to pad the stack by declaring an character array of
- size 12 or 16 (3-4 longwords would do it) to protect the return address.
- I found this out while debugging some assembler code, and when a friend was
- writing code along the lines of
- int foobar(char *str)
- {
- /* stuff */
- return system(str);
- }
- things just wouldn't work out..
-
- I asked him to rewrite the code as:
-
- int foobar(char *str)
- {
- char magic[12];
- /* stuff */
- return system(str);
- }
-
- and things would work, proving that you can't take magic out of
- your program.. :-)
-
- Several years after that I still see people add magic to programs
- using 'system', not knowing why, but stating that it can't hurt.. :-)
-
-
- --------------------------------------------------------
- Jonas Flygare, + Wherever you go, there you are
- V{ktargatan 32 F:621 +
- 754 22 Uppsala, Sweden +
-