[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with FFI in CLISP-1997-08-07
- To: clisp-list@ma2s2.mathematik.uni-karlsruhe.de
- Subject: Problem with FFI in CLISP-1997-08-07
- From: Matthias Lindner <matthias@intellektik.informatik.th-darmstadt.de>
- Date: Wed, 13 Aug 1997 13:28:48 +0200
- In-reply-to: <199708130843.KAA00967@orion.plopp.de>
- References: <199708130843.KAA00967@orion.plopp.de>
- Reply-to: matthias@intellektik.informatik.th-darmstadt.de
Hi,
using the newest CLISP (1997-08-07) on my Linux Box (Linux 2.0.30,
PPro200, 64MB, libc.so.5.4.17) I get severe problems, with FFI CALL-INs.
The following code is a minimal example to reproduce the error:
==== CUT HERE ================================================================
;;; --------------------------------------------------------------------------
;;; File: ltffi.lsp
;;; --------------------------------------------------------------------------
(in-package "TEST-FFI")
(defpackage TEST-FFI
(:nicknames TFFI)
(:use COMMON-LISP FFI)
(:export DO-TEST))
(defun FFI::CALL-IN-FUN (msg)
(format NIL "CALL-IN RECEIVED: ~S.~%" msg))
(def-c-call-in FFI::CALL-IN-FUN
(:name "lisp_call_in")
(:arguments (msg c-string :in :malloc-free))
(:return-type c-string :malloc-free))
(def-c-call-out DO-TEST
(:name "tffi_test")
(:arguments (msg c-string)))
==== CUT HERE ================================================================
/*----------------------------------------------------------------------------
* File: tffi.c
*----------------------------------------------------------------------------
*/
void
tffi_test(char *message)
{
extern char *lisp_call_in(char *msg);
printf("lisp_call_in(%s) -> %s\n", message, lisp_call_in(message));
}
==== CUT HERE ================================================================
Here is, what I do to compile and bind a new clisp:
% make
/src/lisp/clisp/mem/ffi/lisp.run -q -M /src/lisp/clisp/mem/ffi/lispinit.mem -c ltffi.lsp
Compiling file /src/lisp/clisp/test-ffi/ltffi.lsp ...
Compilation of file /src/lisp/clisp/test-ffi/ltffi.lsp is finished.
0 errors, 0 warnings
gcc -g -Wall -I/src/lisp/clisp/mem/ffi -c ltffi.c -o ltffi.o
In file included from ltffi.c:1:
/src/lisp/clisp/mem/ffi/clisp.h:2744: warning: register used for two global register variables
gcc -g -Wall -I/src/lisp/clisp/mem/ffi -c tffi.c -o tffi.o
tffi.c: In function `tffi_test':
tffi.c:6: warning: implicit declaration of function `printf'
rm -f modules.h
for i in ltffi; do \
echo "MODULE($i)" >> modules.h; \
done
gcc -g -Wall -I/src/lisp/clisp/mem/ffi -I. -c /src/lisp/clisp/mem/ffi/modules.c -o modules.o
In file included from modules.d:11:
/src/lisp/clisp/mem/ffi/clisp.h:2744: warning: register used for two global register variables
gcc -o lisp.run modules.o /src/lisp/clisp/mem/ffi/lisp.a ltffi.o tffi.o \
-L/src/lisp/clisp/mem/ffi -lavcall -lvacall -ltrampoline -lintl -ltermcap -lreadline
lisp.run -q -M /src/lisp/clisp/mem/ffi/lispinit.mem -x '(dolist (f (list "./ltffi.fas")) (lisp:gc) (load f)) (lisp:gc) (lisp:saveinitmem) (user::bye)' < /dev/null
;; Loading file ./ltffi.fas ...
;; Loading of file ./ltffi.fas is finished.
NIL
524288
729604 ;
524288
%
Using CLISP-1997-05-03 I get the expected result:
> (lisp-implementation-version)
"1997-05-03 (May 1997)"
> (tffi:do-test "CLISP")
lisp_call_in(CLISP) -> CALL-IN RECEIVED: "CLISP".
> (Bye)
Bye.
The new clisp however gets a SIGSEGV and dies.
Is this a bug, or is there something wrong with my setup or do I
misuse the ffi?
I have tried to disable generational GC, but this did not change
anything.
Another question:
I am writing some kind of daemon using clisp. It uses the ffi a
lot (mySQL interface, tcpip interface etc.) and it would be very
helpful, if there was a way to deal with SIGSEGVs within clisp
(do a restart e.g.). Is there a "canonical" way to do this?
Any help appreciated
--Matthias
------------------------------------------------------------------------------
Matthias Lindner
Wilhelm-Leuschner-Str.46
64293 Darmstadt
Germany
TEL: +49 6151 22071
NET: matthias@intellektik.informatik.th-darmstadt.de
WWW: http://aida.intellektik.informatik.th-darmstadt.de/~matthias/
------------------------------------------------------------------------------