gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: failed to protect memory on Solaris


From: Riccardo Mottola
Subject: Re: failed to protect memory on Solaris
Date: Tue, 15 Jun 2010 02:02:24 +0200
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.1.9) Gecko/20100418 SeaMonkey/2.0.4

Hi,

we discussed this yesterday, this is what I ended up with.
A breakpoint on NSLog will tell you, but this is most likely in NSInvocation's 
code for protecting the buffer containing the trampoline, making sure that it 
is not both writable and executable.  It is possible that your version of 
Solaris has a broken version of mprotect(), or that the GNUstep code is wrong 
in some way.

mprotect() wants a page-aligned address on Solaris.
- valloc instead of malloc, valloc just one page
- mprotect exactly that page, not size
- before freeing, make the page writable again.

This works for me on Solaris/Sparc, FreeBSD/x86. Does it work for you? It should be valid for all platforms.

Things to possibly improve
- remember the size of the page and use that one
- remember that we valloc'd a page and not "size"
- some platforms might not have valloc(), should we use malloc()? THose platforms will be probably small/restricted/old and might not have mprotect/mmap

To check about the pages I inserted a NSAssert() to ease debugging.

Riccardo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]