This is the mail archive of the
mailing list for the Cygwin project.
problems with mprotect()
- From: Anonymous <tironsi at yahoo dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 23 Sep 2002 19:21:22 -0700 (PDT)
- Subject: problems with mprotect()
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];
mprotect(ptr, pgSize, 0);
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:
$1 = 0xa012818 ""
$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!
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html