[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Official Bug with Calling NewGWorld in MACL?

Here's the text of that bug report (submitted 6/1/90 to MacDTS).  Note that
the bug in the IIci ROM doesn't prevent our use of the new QD32 Graphic World
traps.  It's an isolated condition that we just programmed around.  Specifically
you have to be careful that the bounds rectangle you pass to NewGWorld is
contained in an active device (screen).  Other than that, we have been
successfully using the QD32 traps.

BUG REPORT GQI #4: Fatal bug in 32-bit QuickDraw in Mac IIci ROM

The 32-bit QuickDraw routine NewGWorld in the Mac IIci ROM contains a bug which
can cause a bus error when given certain legal(!) arguments.  Consider the
following call (refr: Develop Journal, Jan. 90, p. 34):

NewGWorld(offscreenGWorld, pixelDepth, boundsRect, cTable, aGDevice, flags);

If pixelDepth is 0, then NewGWorld does an internal call to GetMaxDevice to get
the handle of the deepest device that intersects boundsRect (refr: IM-V, p.
125).  The documentation in IM-V for GetMaxDevice doesn't specify what it
returns if boundsRect does not intersect any device, but if that's the case,
it does something which seems reasonable -- it returns nil (i.e., 0).

NewGWorld is not prepared to deal with this eventuality; it goes merrily
chasing down the nil pointer as if it were a handle to a device and aborts
with a bus error at ROM location 4083FBC0.

To reiterate:
	pixelDepth = 0
	boundsRect not intersecting any device
cause NewGWorld to crash on a Mac IIci running System 6.0.5.  (Note: We haven't
checked the non-ROM version of 32-bit QD on earlier Mac II's.)

We were using NewGWorld to set up an offscreen environment to handle dehigh-
lighting of selected objects in a scrolling window (in our application written
in Macintosh Allegro Common Lisp).  So the following sequence was causing bus
errors, much to our bewilderment:
	1. Select an object or objects -- highlighting appears.
	2. Scroll around such that the selected objects are off screen (not
	just outside the window).
	3. Click anywhere to select a new object -- invokes our code to
	dehighlight the previous selection.
	===> BOOM!

We have solved the problem in our dehighlighting code by doing a direct call to
GetMaxDevice on boundsRect and only calling NewGWorld if we get a handle back.

It took awhile to determine that step 2 above was the critical factor, espec-
ially since this bug was intertwined with a bug in MACL with similar symptoms
(i.e., crashes when selecting or deselecting objects).

Mike Wirth                             Chris Wakefield
GeoQuest Intl.                         Newpoint MicroSmiths
Houston                                Houston
mcw@rice.edu (preferred)               D0966@AppleLink
D1542@AppleLink (alternate)

The response from MacDTS wasn't especially helpful: "Oh, ya.  That's a KNOWN

Mike Wirth