[Ecls-list] DFFI issues
Waldek Hebisch
hebisch at math.uni.wroc.pl
Tue Apr 8 02:08:45 UTC 2008
Juan Jose Garcia-Ripoll wrote:
> On Sun, Apr 6, 2008 at 3:52 PM, Luis Oliveira <luismbo at gmail.com> wrote:
> > I was trying to update cffi-ecl.lisp and came across this apparent bug:
>
> > > (si:find-foreign-symbol "abs" :default :pointer-void 0)
> > #<foreign :POINTER-VOID 00002b82f51bc8e0>
> > > (si:call-cfun * :int '(:int) '(-42))
> > Segmentation violation.
> >
> > I'm running Ubuntu 7.10, in case that helps.
> >
> > $ uname -srm
> > Linux 2.6.22-14-generic x86_64
>
> This must be related to the FFI backend for intel 64-bits processors.
> I will have a look.
>
I took a quick look at src/c/arch/ffi_x86_64.d file.
The 'ecl_fficall_execute' function looks like asking for breakage.
Namely, this function contains asm statements which modify registers and
apparently assume that C part will preserve values stored in
registers. Worse, the asm statement modifies stack pointer
and counts that following C code will work. AFAICS a small change
to C compiler may break this code -- I would say that this function
should be written in assembler. As alternative, a "known working"
assembler output could be used for normal build (such output
would be updated only when C part changes).
However, the problem seem to be earlier -- gdb shows that segfault
is in ecl_fficall_push_arg. The reason is null pointer -- the
registers field in *(cl_env.fficall) structure is a null pointer.
It looks that ecl_fficall_prepare_extra function is supposed to
initialize registers structure, but:
- this function does not return freshly allocated structure
- I was unable to find anybody calling it.
--
Waldek Hebisch
hebisch at math.uni.wroc.pl
More information about the ecl-devel
mailing list