Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <20020924022122.38538.qmail@web20422.mail.yahoo.com> Date: Mon, 23 Sep 2002 19:21:22 -0700 (PDT) From: Anonymous Subject: problems with mprotect() To: cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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
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/