[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] Re: Chicken-hackers Digest, Vol 15, Issue 5
From: |
Ben Kurtz |
Subject: |
[Chicken-hackers] Re: Chicken-hackers Digest, Vol 15, Issue 5 |
Date: |
Tue, 20 Nov 2007 18:07:49 -0500 |
You're completely correct, the one big issue is page alignment.
Assuming that you are malloc'ing exactly one page, this should work
fine on OSX as well as Linux.
Well, not "fine" exactly - This is undefined in POSIX because many
things about memory page alignment are not standardized, which means
that any code you write will be particularly susceptible to bit-rot
(kernel or hardware changes could break it).
Are you doing this to make a block executable?
If you have some test code, I'd be happy to compile and run it on OSX for you.
- B
> On Mon, 19 Nov 2007, felix winkelmann wrote:
>
> > Hi!
> >
> > A question to the unix hackers:
> >
> > Is it legal to call mprotect() on memory allocated via malloc()? (yes,
> > properly
> > aligned to page boundaries). On Linux it seems to work, but according to
> > POSIX it is undefined. What about BSD/Mac systems?
> >
> >
> > cheers,
> > felix
> >
> >
> > _______________________________________________
> > Chicken-hackers mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/chicken-hackers
> >
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 20 Nov 2007 08:01:18 +0100
> From: "felix winkelmann" <address@hidden>
> Subject: Re: [Chicken-hackers] mprotect on malloc'ed memory?
> To: Elf <address@hidden>
> Cc: chicken <address@hidden>
> Message-ID:
> <address@hidden>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Nov 20, 2007 4:16 AM, Elf <address@hidden> wrote:
> >
> > um, if im understading the openbsd pages right, it might work, but it wont
> > necessarily protect only the page. according to POSIX, its not undefined,
> > its
> > an error to use mprotect on anything but mmapped regions. at a guess, even
> > if it does happen to work, you'll be looking at a lifetime of unpredictable
> > and undebuggable SIGSEGVs. may i ask the intended purpose of mprotecting
> > regular memory?
> >
>
> As a rather handy debugging aid: my making the current tospace (the unused
> half of the heap) non-accessable, usage of dead memory can be found (which
> happens frequently in FFI code by keeping references to already GC'd memory).
> It's just an optional debugging feature for the situations where you need
> every
> help you can get.
>
>
> cheers,
> felix
>
>
>
>
> ------------------------------
>
> _______________________________________________
> Chicken-hackers mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-hackers
>
>
> End of Chicken-hackers Digest, Vol 15, Issue 5
> **********************************************
>
>
- [Chicken-hackers] Re: Chicken-hackers Digest, Vol 15, Issue 5,
Ben Kurtz <=