[cffi-devel] Array call crashes SBCL on one computer

Stephen Compall s11 at member.fsf.org
Sun Mar 19 20:09:45 UTC 2006


On Sun, 2006-03-19 at 12:53 -0500, Liam M. Healy wrote:
>  - The desktop is ..., Darcs pull 2006-03-07 23:11, SBCL 0.9.8.42
>  - The laptop is ..., Darcs pull 2006-03-17 23:59, SBCL 0.9.9

This may or may not be an issue.

> (with-foreign-objects ((retn :double))
>   (foreign-funcall "gsl_sf_bessel_Jn_array"
> 		   :int 0
> 		   :int 2
> 		   :double 0.25d0
> 		   :pointer retn
> 		   :int)
>   (mem-aref retn :double 0))

I know nothing about GSL besides what I just read about the function you
call above, but don't you need to allocate space for 3 doubles, not just
one, for the retn (result_array) argument?

Function: int gsl_sf_bessel_Jn_array (int nmin, int nmax, double x, double result_array[])
        This routine computes the values of the regular cylindrical
        Bessel functions J_n(x) for n from nmin to nmax inclusive,
        storing the results in the array result_array. The values are
        computed using recurrence relations for efficiency, and
        therefore may differ slightly from the exact values.

> - All functions I've tried that return a pointer to an array of doubles
> have this problem.
> - Sometimes the problem behavior varies.  For example, If the third
> argument is 0.5d0, SBCL simply locks up instead of crashing.
> Sometimes I get an infinite output of error messages that repeat the
> line "mprotect: Cannot allocate memory" over and over.
> 
> Any debugging advice?

If the above didn't help, try to rewrite the crashing behavior using
SB-ALIEN: http://www.sbcl.org/manual/Foreign-Function-Interface.html

If you still get the crash, it may be an issue with misinterpretation,
or SB-ALIEN.  Otherwise, it may be a problem with how CFFI uses
SB-ALIEN.

-- 
Stephen Compall
http://scompall.nocandysw.com/blog
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20060319/7730a1fe/attachment.sig>


More information about the cffi-devel mailing list