This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: closure api problems


Aaron Patterson wrote:

> I'm doing my best to get a simple example using the closure API working.
> I think I'm missing something simple, but I'm not sure what it is!
> 
> I've installed libffi from master (on github) to my home directory and
> compiled and linked the cls_uchar.c example against that, and I always
> end up with a Bus Error.
> 
> Here is the output from my shell:
> 
>     $ pwd
>     /Users/apatterson/git/libffi
>     $ git status
>     # On branch master
>     nothing to commit (working directory clean)
>     $ gcc -o foo \
>     -I/Users/apatterson/lib/libffi-3.0.9rc1/include/ -I. \
>     -L/Users/apatterson/lib testsuite/libffi.call/cls_uchar.c -lffi
>     $ ./foo
>     Bus error
>     $
> 
> Here is the (unfortunately not too helpful) gdb stack trace:
> 
>     (gdb) run
>     Starting program: /Users/apatterson/git/libffi/foo 
>     Reading symbols for shared libraries ++. done
>     
>     Program received signal EXC_BAD_ACCESS, Could not access memory.
>     Reason: KERN_PROTECTION_FAILURE at address: 0x0000000100100080
>     0x0000000100100080 in ?? ()
>     (gdb) bt
>     #0  0x0000000100100080 in ?? ()
>     #1  0x0000000100000da4 in start ()
>     (gdb)
> 
> I'm running 64bit OS X (Snow Leopard).  Any help would be greatly
> appreciated!

I think Snow Leopard forbids exec permission on data memory.
You need to make sure that FFI_MMAP_EXEC_WRIT is set in closures.c.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]