chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] mprotect on malloc'ed memory?


From: Ivan Raikov
Subject: Re: [Chicken-hackers] mprotect on malloc'ed memory?
Date: Mon, 19 Nov 2007 16:26:11 +0900
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

  I don't think you are supposed to call mprotect on malloc'ed
memory. If it "worked" in Linux, that's probably because the glibc
malloc _sometimes_ uses mmap, and _sometimes_ uses brk, and you were
probably calling mprotect on mmapped pages. If the *BSD
implementations of malloc also use mmap, then you might get lucky, but
you are basically relying on unspecified behavior, and the results
would probably be unpredictable.


    -Ivan
  

"felix winkelmann" <address@hidden> writes:

> 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
>




reply via email to

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