This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: closure api problems
- From: Andrew Haley <aph at redhat dot com>
- To: Aaron Patterson <aaron at tenderlovemaking dot com>
- Cc: libffi-discuss at sourceware dot org
- Date: Mon, 16 Nov 2009 19:45:36 +0000
- Subject: Re: closure api problems
- References: <20091113181408.GA50592@hartaseberly.yellowpages.local>
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.