Hi all,
I've been messing around trying to get Age of Empires II working, and
I've come across what I believe is a bug in the Wine implementation of
VirtualFree(). I searched the website, but this issue doesn't seem to
have come up before.
The problem appears to be using the VirtualFree() function with the
MEM_DECOMMIT flag on a section of memory that hasn't been allocated by
VirtualAlloc(). I have no idea why AOE2 is doing this (it may be
related to another bug or something), but it's definitely legal under
Windows. In particular, I tried this under NT4:
BOOL result = VirtualFree((LPVOID)0x5192fc71, 0x3fe7, MEM_DECOMMIT);
This returns 0 (as a failure indicator), but it does not give any sort
of exception. This section of memory is definitely not allocated on
my NT box - VC6 shows it all as illegal addresses.
Under Wine when AOE2 tries to do this on a non-NULL pointer that
wasn't allocated with VirtualFree(), it gives the following messages
to the log file (+relay):
Call kernel32.712: VirtualFree(5192fc71,00003fe7,00004000)
ret=004c578d fs=008f
Ret kernel32.712: VirtualFree() retval=00000001 ret=004c578d fs=008f
Call kernel32.702: UnhandledExceptionFilter(404a4ce8) ret=0061d6da
fs=008f
Call user32.422: MessageBoxA(00000000,404a4a14 "Unhandled page fault
on read access to 0x5192fc75 at address 0x0052c42d.\nDo you
"...,400facdc "Error",00000014) ret=400dcade fs=008f
This is obviously very truncated to just the above 4 lines.
Anyways, I'm curious to know if this is a known issue, and what we can
do about it. I'm not about to start mucking around inside an
important function like VirtualFree() without some confirmation that
is an actual bug. :) I am very willing to aid in any way, though,
once its bug-status has been confirmed.
The info about the VirtualFree() function is available at:
http://msdn.microsoft.com/library/psdk/winbase/memman_0dr9.htm
In particular, this section seems important:
"An attempt to decommit an uncommitted page will not cause the
function to fail. This means that a range of committed or uncommitted
pages can be decommitted without having to worry about a failure."
Thanks in advance for any advice/help/patches!
- Ken.
[EMAIL PROTECTED]