Hi, I'm having segfaults with the following piece of code (working from WinXP SP1 using latest Cygwin release):
char * AllocBoundedArray(int size) { int pgSize = getpagesize(); char *ptr = new char[pgSize * 2 + size]; // before mprotect(ptr, pgSize, 0); // after mprotect(ptr + pgSize + size, pgSize, 0); return ptr + pgSize; } In gdb I get the following message when I do a print ptr before and after the mprotect() line: // before $1 = 0xa012818 "" // after $2 = 0xa012818 <Address 0xa012818 out of bounds> also pgSize = 4096 and size = 16384 and I get a seg fault after the return statement The code works fine on this same machine under linux. I don't really understand how the code works (I just traced my seg fault here) as I am a C++ newbie, so forgive me if I have missed something. __________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/