[cffi-devel] Re: [Sbcl-devel] Re: CFFI Callbacks on SBCL

Thomas F. Burdick tfb at ocf.berkeley.edu
Sun Jan 1 11:04:40 UTC 2006


On 12/31/05, Juho Snellman <jsnell at iki.fi> wrote:
> <luismbo at gmail.com> wrote:
> > We're not even testing if the callback moves or not. Our libtest is
> > not saving the callbacks' address.
> >
> > Here's the a testcase, using sb-alien (sort of):
>
> Thanks. The problem is that the callback support assumes that
> #'SB-VM::ENTER-ALIEN-CALLBACK can never move [*]. Which is no
> longer true on x86 and x86-64 as of a few releases ago, since
> everything is in the dynamic space by default, and will get
> relocated when the core is saved [**].

Okay, that makes sense now.  Any pointers to the discussion of why
purify doesn't happen by default anymore on those platforms? 
(curious).

> A workaround is to run PURIFY once before creating any callbacks. The
> proper solution would be adding a level of indirection into the
> generated callback wrappers. Maybe make 'SB-VM::ENTER-ALIEN-CALLBACK a
> static symbol, so that it will be guaranteed to not move, and then
> emit instructions to peek into its symbol-function slot.

The layout of symbols is unlikely to change soon, so that will work
fine.  But another option would be to cater to what the trampolines do
now and move the ENTER-ALIEN-CALLBACK function to static space.



More information about the cffi-devel mailing list