Crash after accessing parts before allocated memory

Fabian Maurer dark.shadow4 at web.de
Thu Nov 17 11:08:13 CST 2016


This is a kind-of follow up to "Debugging wine and finding the cause of a 
crash", but another question.

The program I'm debugging works reliably on windows/ReactOS, but on wine it 
crashes every time. I can get it to work by hacking RtlAllocateHeap to always 
allocate 5500 bytes more than needed, but that's hardly a solution.

>From what I currently know, the issue stems from a few negative offsets being 
added on a pointer returned from RtlAllocateHeap. On windows this leads to 
accessing a memory region filled with zeroes, on wine it accesses random 
memory. The program can handle nullpointers, but not bogus pointer.

Any ideas how to deal with that, or is UB like that just a no-go? I have zero 
knowledge about the internal management of the heap, so help would be 
appreciated. At least is seems suspicious subtracting something from a pointer 
it got from RtlAllocateHeap, but maybe there's some plan behind it.



More information about the wine-devel mailing list