Robert Reif reif@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.