[net.micro.mac] Bad Megamax bug if you use modaldialog in a DA

mkg@lzaz.UUCP (Marsh Gosnell) (02/04/86)

I have uncovered a rather nasty bug in Megamax (version 2.1b) that will
occasionally cause crashes.  The bug exists in any DA that has dNeedTime
set and uses modaldialog (the Standard File Manager uses modaldialog).

The bug is causd by the way Megamax manages the block of heap storage
allocated to the global/string storage.  Megamax allocates the block on the
the first open of the DA, places the handle in dctlstorage, and also in A4.
All user code references the globals and strings relative to A4.  The glue
routines for the control, close, etc. entries supplied by Megamax lock the
block upon entry and unlock it when it exits.

The problem with using modaldialog is that it calls SystemEvent which in turn
periodically calls the control routine of each DA that have the dNeedTime bit
set.  If your DA has that bit set, your control routine will be called WHILE
you are inside modaldialog.  Where you get into trouble is that when this
call to the control routine exits, your global block is unlocked while you
are still inside modaldialog!!  If the heap gets shuffled before you return,
you are in BIG trouble.  A4 still points to the old location of the block
when it has been moved to a new location in the heap and you get "interesting"
results (usually address error traps).

The fix I'm suggesting to Megamax (thanks to Steve Brecher) is to check if the
block is locked when you enter the control routine.  If it is, don't unlock it
when you're finished.  In the mean time, I've removed the dNeedTime bit from
my DA's flags.
    Marsh Gosnell   ihnp4!lzma!mkg

werner@ut-ngp.UUCP (Werner Uhrig) (02/10/86)

is that the same problem that causes anything compiled with Megamax to lead
to a crash when quitting from it while SkipFinder-5.3 is active?

I noticed it with FastEddie, told the author about it who then cut his
program down to "nothing" ("Hello World" and less) and the problem persisted.

I then talked to Darin Adler (of SkipFinder, Deja-Vue, and other reasons to
be impressed), and he indicated that he can (and hopefully will) make
SkipFinder live the problem caused by Megamax' doing something-or-other not
according to standard rules.

BTW - I don't believe I've seen SkipFinder-5.3 posted on USENET; I know
Darin posted it to Delphi or CompuServe, and to INFO-MAC (where it probably
rots awaiting for some decision of the people at SUMEX how to revive the
group - there's a meeting scheduled to take place Feb 11 to decide "what next")

Please, no need to post or mail about SkipFinder-5.3;  I'll look into it and
ask Darin to post it again (or allow me to post it).

	---Werner