[ros-kernel] "My Computer" crash
Mark Tempel
mtempel at visi.com
Tue Feb 17 22:02:09 CET 2004
Quoting Ge van Geldorp <ge at gse.nl>:
> When double-clicking on "My Computer" in VMware, Explorer would often
> crash, shutting down the system. I finally tracked it down to
> HeapAlloc() not always returning 8-byte aligned blocks (sometimes it
> would return blocks at xxxxxxx4 or xxxxxxxC). This causes
> Local/GlobalAlloc to misbehave. Someone before me already tried to fix
> it:
That was me.
> phandle = RtlAllocateHeap(GetProcessHeap(), 0,
> sizeof(GLOBAL_HANDLE));
> /* This little hack is to make sure that we get a pointer with 8-byte
> ** alignment.
> ** Fixme: When we are sure all allocations are 8-byte aligned,
> ** we can remove this hack.
> */
> if (ISPOINTER(INTERN_TO_HANDLE(phandle)))
> {
> hack_fix = RtlAllocateHeap(GetProcessHeap(), 0,
> sizeof(GLOBAL_HANDLE));
> RtlFreeHeap(GetProcessHeap(), 0, phandle);
> phandle = hack_fix;
> }
>
> Unfortunately, the 2nd call to RtlAllocateHeap() was not guaranteed to
> return an 8-byte aligned block either. The end result was that
> GlobalAlloc returned what looked like a pointer while in reality it was
> a handle. Via a series of 4 memory overwrites this finally caused the
> crash. A small debugging nightmare I might add.
Crap. Sorry about that. I should have spun on the allocate heap till I got an 8
byte aligned block, but I like your fix better.
> Normally, I wouldn't bother y'all with this. However, I fixed it by
> adjusting some structures in reactos/lib/ntdll/rtl/heap.c and making a
> change to one of these low-level memory allocation routines while we're
> in a freeze period makes me feel slightly uneasy. OTOH, the problem in
> my opinion was seriously enough to need a fix ASAP.
This is extremly important. It should be included.
one question: Did you remove the kludge code in GlobalAlloc ?
--mark
More information about the Ros-kernel
mailing list