home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / next / misc / 23477 < prev    next >
Encoding:
Internet Message Format  |  1993-01-04  |  4.0 KB

  1. Xref: sparky comp.sys.next.misc:23477 comp.sys.next.programmer:7971
  2. Newsgroups: comp.sys.next.misc,comp.sys.next.programmer
  3. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!cameron
  4. From: cameron@symcom.math.uiuc.edu (Cameron Smith)
  5. Subject: Re: Can't get unsit-15.shar to compile under 2.1 on '030
  6. References: <C09xLx.G48@news.cso.uiuc.edu>
  7. Message-ID: <C0BEr7.337@news.cso.uiuc.edu>
  8. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  9. Organization: none
  10. Date: Mon, 4 Jan 1993 05:47:30 GMT
  11. Lines: 66
  12.  
  13. Thanks to all who have responded to my request for help with "unsit".
  14. Please *don't* respond any more to that request as the problem has
  15. been found and fixed.  (But the fix itself baffles me, so if you want
  16. to think about a *new* puzzle, read on...)
  17.  
  18. * So far everyone who has responded has told me to get the version of
  19.   "unsit" that's part of "Opener".  Actually, the version in "Opener"
  20.   is almost identical to the version that's all over the net (according
  21.   to archie) under the name "unsit-15.shar".  The only change is that
  22.   the Opener version doesn't try to dialog with the user before
  23.   over-writing a file.  This has absolutely no effect on the problem
  24.   I've been having.  In fact, I pulled out the unsit executable from
  25.   the Opener distribution and verified that, when asked to un-Stuff
  26.   the particular archive I've been working with, it dies in exactly
  27.   the same way as the version I compiled myself.
  28.  
  29. * The problem has been absolutely, unmistakably traced to a pointer
  30.   running off the end of an array.  At one point in "unsit.c" an
  31.   array is dimensioned with a size of 512, with the comment that
  32.   "/* 512 should be big enough */".  At another place, a pointer
  33.   is initialized to the head of the array and repeatedly incremented
  34.   (via ++) to loop through the array.  It's supposed to stop when
  35.   it sees a sentinel value, but there is *NO* provision in the code
  36.   to keep it from running off the end of the array if the sentinel
  37.   isn't among the first 512 elements.  By sheer cosmic coincidence,
  38.   the very first StuffIt archive I tried to un-stuff after re-compiling
  39.   unsit under 2.1 contained a member whose Huffman tree had more than
  40.   512 elements.  BLAM!  Tracing confirms that the bad output begins
  41.   as soon as the (nonexistent) 513th element is assigned (because a
  42.   crucial variable that immediately follows the array in memory
  43.   is clobbered).
  44.  
  45. * I have "fixed" the problem by inserting an explicit test, and
  46.   arranging for the program to die informatively when the overrun
  47.   occurs.  I have "verified" the fix by first exercising my trap,
  48.   then re-compiling with a larger array size; the problem goes away
  49.   and and the archive extracts just fine once the array is made
  50.   big enough to hold the decoding tree.  (A *real* fix would involve
  51.   redesigning the Huffman decoder to allocate memory dynamically;
  52.   I do *not* plan to do this, since the static version has apparently
  53.   worked nearly 100% of the time for nearly 100% of the users for
  54.   three years now.)
  55.  
  56. * As soon as I've had a chance to write up a little blurb about
  57.   this, I plan to package up an archive containing the old and new
  58.   code, and I'll submit it to wherever is appropriate.  (But I want
  59.   to try to contact the original author first -- I'm awaiting an
  60.   answer to my email.)
  61.  
  62. Now for the $64,000 question--
  63.  
  64. * What still puzzles me is... *WHY* did the old binary that I compiled
  65.   under NS 1.0 *not* die in the same way on the same input?  It merrily
  66.   chugs along and successfully un-stuffs the entire archive.  I can
  67.   only conclude that its variables are laid out in memory in a different
  68.   way, so that the array overrun clobbers space that would otherwise
  69.   have been unused, instead of clobbering other variables.
  70.  
  71. I would be MOST grateful for an explanation of this phenomenon.
  72. But more pointers to other versions of unsit (or to Opener) are not needed.
  73.  
  74. My sincere thanks, though, to all who took the time to try to help.
  75. It is really much appreciated.
  76.  
  77. --Cameron Smith
  78.   cameron@symcom.math.uiuc.edu
  79.