Mail Archives: cygwin/2004/09/28/08:33:13
Hi, All!
This message is related to my previous post about diff crashing on Itanium, Windows Server 2003
(http://cygwin.com/ml/cygwin/2004-09/msg00465.html). During debugging I found out that the problem is in
CreateFileMapping/MapViewOfFileEx behavior on this particular platform. Somehow these functions return OK status but
when you try to write something to the area allocated, everything crashes down. The following is the illustration of
the problem:
int main(int argc, char* argv[])
{
HANDLE h = NULL;
void *base = NULL;
__try {
SECURITY_ATTRIBUTES sec_none;
sec_none.nLength = sizeof(sec_none);
sec_none.bInheritHandle = TRUE;
sec_none.lpSecurityDescriptor = NULL;
int len = 16 * 1024;
h = CreateFileMapping(INVALID_HANDLE_VALUE, &sec_none, PAGE_WRITECOPY,
0, len, NULL);
if (!h) {
printf(\"FAIL: CreateFileMapping(...)\\n\");
return -1;
}
printf(\"PASS: CreateFileMapping(...)\\n\");
base = MapViewOfFile(h, FILE_MAP_COPY, 0, 0, len);
if (!base) {
printf(\"FAIL: MapViewOfFile(...)\\n\");
return -1;
}
printf(\"PASS: MapViewOfFile(...), base = 0x%08x\\n\", base);
int tmp;
tmp = *((int*)base);
printf(\"PASS: Reading memory\\n\");
*((int*)base) = tmp;
printf(\"PASS: Writing memory\\n\");
}
__finally {
if (base) {
UnmapViewOfFile(base);
base = NULL;
}
if (h) {
CloseHandle(h);
h = NULL;
}
}
return 0;
}
If you compile this code with 32-bit compiler and then run it on 64-bit Server 2003 it will crash. At the same time it
works on 32-bit machines.
So the questions is to cygwin developers: what can be done next? I\'ve found file wincap.cc with particular platforms
capability descriptions. I\'ve tried to set has_working_copy_on_write to false when IsWow64Process return true and it
seems to work, but how can I be sure that I didn\'t break anything else? Are there any tests or something? And generally
is this fix OK? Which drawbacks can it have? If the fix is OK - let me know, I will provide a patch.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -