home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / folklore / computer / 16435 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  1.8 KB

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