At 4:23 PM -0700 7/19/99, Shannon wrote:
>Some users are reporting crashes on a Palm VII. The crash happens right
>when I use MemDeref on a locked handle.
You should never use MemDeref on a locked handle!
MemDeref is a weird old debugging function that unmunges the handle and
follows the master pointer. This gives you the address of the chunk, just
like you'd get from MemHandleLock, but without locking it down.
So it's a lot like keeping the pointer after you've called MemHandleUnlock
-- e.g. a bad idea. If an allocation kicks off a compaction, or if you
have the right debugging switches, the chunk will move (because it's not
locked) and your pointer will be bad.
Some of the built-in apps (which we ship as sample code) use MemDeref as an
easy way to get the pointer from a handle without locking it an extra time.
That's still ugly, but at least it's not a bug. You should not do that --
just use MemHandleLock to get the pointer legitimately.
--Bob