VirtualProtect bug?

Alexandre Julliard julliard at winehq.org
Tue May 18 16:04:52 CDT 2004


Robert Reif <reif at earthlink.net> writes:

> I'm trying to write a test that checks for data overruns
> using VirtualAlloc and VirtualProtect and I think
> I may have found a bug.  Here is the problem:
>
> DWORD dwPageSize;
> BYTE * twoPages, temp;
> DWORD flOldProtect;
> twoPages = VirtualAlloc(NULL, 2 * dwPageSize, MEM_RESERVE |
> MEM_COMMIT, PAGE_READWRITE);
> res = VirtualProtect(twoPages + dwPageSize, dwPageSize, PAGE_NOACCESS,
> &flOldProtect);
> temp = twoPages[dwPageSize + 1];    // should cause exception but
> doesn't in wine
> twoPages[dwPageSize + 1] = 0;        // does cause exception

Most likely the read access was optimized out. Try doing the access
through a volatile pointer.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list