[comp.sys.mac.programmer] Interesting Bug :-)

ml10+@andrew.cmu.edu (Michael A. Libes) (11/07/90)

I was helping a friend debug his resource editor and discovered a very
interesting bug.

The symptom was as follows:
    A dialog box lets you choose an icon to edit
    There is a "get info" button in the dialog which gives you the
     icon's name and id.  This is the procedure IconInfo.
    On some files, when you pushed the info button, the machine hung
    The Think C debugger hung before stepping into the IconInfo procedure.

The bug?  We discovered that the problem occurred only when the file you
were editing was an application.  I guessed that the CODE resource
containing IconInfo was not loaded, and the LoadSegment was loading the
CODE resource from the file you are editing instead of the actual
resource editing application.  However, according to MacsBug, the CODE
resource was loaded.
It turns out that one of the CODE resource which THINK C puts its
runtime code, i.e. ID#0 or ID#1, was the culprit.  It was unloaded for
some reason unknown to me, and calling IconInfo caused it to be loaded. 
This bug trashed the system file a few times and one partition on my
friend's hard drive.

Only on the Mac :-)


------------------------------------------------------------------
Michael Libes  (Luni)                    Internet Address:
MacMach Project                           ml10@andrew.cmu.edu
Carnegie Mellon University
------------------------------------------------------------------