| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Date: | Tue, 24 Sep 2002 16:41:30 +0200 |
| From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: problems with mprotect() |
| Message-ID: | <20020924164130.Q29920@cygbert.vinschen.de> |
| Reply-To: | cygwin AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| References: | <20020924022122 DOT 38538 DOT qmail AT web20422 DOT mail DOT yahoo DOT com> |
| Mime-Version: | 1.0 |
| In-Reply-To: | <20020924022122.38538.qmail@web20422.mail.yahoo.com> |
| User-Agent: | Mutt/1.3.22.1i |
On Mon, Sep 23, 2002 at 07:21:22PM -0700, Anonymous wrote:
> 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;
> }
The code expects that a new or malloc returns the memory on a
page boundary. That's incorrect. It's virtually certain that
it protects memory to NOACCESS which isn't owned by the above
new(). Whatever this is, it's non-portable.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin AT cygwin DOT com
Red Hat, Inc.
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |