libffcall
[Top][All Lists]
Advanced

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

Re: [bug #66089] On macos mprotect can't be PROT_WRITE and PROT_EXEC at


From: Lorenzo Daneo
Subject: Re: [bug #66089] On macos mprotect can't be PROT_WRITE and PROT_EXEC at the same time
Date: Wed, 14 Aug 2024 20:19:11 +0200

Thank you,

I just tried to recompile with HAVE_MMAP_SHARED_CAN_EXEC = 1 and HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC = 0 but it doesn't work.
I paste the stack:
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x0000000197786a60 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x000000010074abe8 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x00000001976cba30 libsystem_c.dylib`abort + 180
  * frame #3: 0x00000001004c3370 libffcall.0.dylib`callback_trampoline_alloc.cold.2 at trampoline.c:448:67 [opt]
    frame #4: 0x00000001004c0474 libffcall.0.dylib`callback_trampoline_alloc(address=(libffcall.0.dylib`callback_receiver), data0=0x0000000100002eb4, data1=0x0000600001ae8060) at trampoline.c:448:19 [opt]
    frame #5: 0x0000000100002ea8 CTest`alloc_void_call_void(the_this=0x000000011f604880, the_func=0x000000010000386c) at callback.c:73:12
    frame #6: 0x0000000100002a5c CTest`create_deck at deck.c:15:27
    frame #7: 0x0000000100002694 CTest`init_game(n_players='\x02') at game.c:12:18
    frame #8: 0x0000000100002640 CTest`main(argc=1, argv=0x000000016fdff528) at main.c:14:20
    frame #9: 0x00000001974360e0 dyld`start + 2360

The reason is here:
page = (char*)mmap(NULL,pagesize,PROT_READ|PROT_WRITE,MAP_SHARED,file_fd,file_length);
page_x = (char*)mmap(NULL,pagesize,PROT_READ|PROT_EXEC,MAP_SHARED,file_fd,file_length);

The second mmap is not working.

Lorenzo

Il giorno mer 14 ago 2024 alle ore 20:09 Bruno Haible <INVALID.NOREPLY@gnu.org> ha scritto:
Follow-up Comment #3, bug #66089 (group libffcall):

Lorenzo Daneo wrote in
https://lists.gnu.org/archive/html/libffcall/2024-08/msg00003.html :
> the installation with brew was going in error at line 87 in trampoline.c

On macOS, HAVE_MMAP_SHARED_CAN_EXEC is supposed to be defined to 1.

Can you please look in the config.log what happened to the "checking whether a
shared mmap can make memory pages executable..." test? This test ought to
succeed.

> compiled locally with HAVE_MPROTECT_AFTER_MMAP_CAN_EXEC set to 1

This won't work. The reason HAVE_MMAP_SHARED_CAN_EXEC was introduced is that,
precisely, mprotect (PROT_READ|PROT_WRITE|PROT_EXEC) does not work on macOS
and some other operating systems.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?66089>

{savane: Include the next line when replying by email.}
{savane: user = 362990; tracker = bugs; item = 66089}

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

reply via email to

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