Re: [AD] More "mprotect" troubles (4.2.1 showstopper?)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2006-03-13, Hans de Goede <j.w.r.degoede@xxxxxxxxxx> wrote:
> That is what the current code did, but appereantly mprotect on malloces 
> mem is a no no, mprotect is (officially, POSIX) only supported on mmap 
> returned mem. So either we must create a mmap once the current 
> scratchmem using code is done and then memcopy the code, or (as I have 
> done) replace scratchmem by an mmap based scratchmem implementation 
> (I've only replaced it for the use in code generation). This will 
> actually be faster then the old way, since mremap should be much faster 
> then realloc.

> @@ -439,7 +441,7 @@
>   #ifdef ALLEGRO_WINDOWS
>     /* Play nice with Windows executable memory protection */
>     VirtualProtect(_scratch_mem, _scratch_mem_size, PAGE_EXECUTE_READWRITE, &old_protect);
> - #elif defined(HAVE_MPROTECT)
> + #elif defined(HAVE_MPROTECT) && !defined(USE_MMAP_GEN_CODE_BUF)
>     {
>        char *p = (char *)((unsigned long)_scratch_mem & ~(PAGE_SIZE-1ul));
>        if (mprotect(p, _scratch_mem_size + ((char *)_scratch_mem - p),
> @@ -448,22 +450,29 @@

Hi, this part of the code is missing from Allegro.  I recognised it from
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=185214 but are
there any more changes required?  A patch would be appreciated if you
have one ready.

Peter

PS. For other developers: Hans' patch will almost apply to the 4.2.x
Subversion branch, as long as you make the changes malloc -> _AL_MALLOC,
free -> _AL_FREE.





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/