-
-
Save rpav/fa8f380a218b55b4ae6a to your computer and use it in GitHub Desktop.
SBCL-1.0.58 / CFFI crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(eval-when (:compile-toplevel :load-toplevel :execute) | |
(asdf:load-system :cffi)) | |
(defpackage :test-crash | |
(:use :cl :cffi)) | |
(in-package :test-crash) | |
(eval-when (:compile-toplevel :load-toplevel :execute) | |
;; Change to appropriate path, of course: | |
(load-foreign-library "/home/rpav/test.so") | |
(defcfun call_callback :int | |
(fn :pointer))) | |
(defcenum status_t | |
(:success 0)) | |
(declaim (inline make-point)) | |
(defstruct point x y) | |
(defcallback my-callback status_t () | |
(let* ((p (make-point :x 0.0 :y 0.0))) | |
(declare (dynamic-extent p)) | |
(format t "~&~0,0T~A = ~S~%" "P" P)) | |
:success) | |
(call_callback (cffi:callback my-callback)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This can be built simply: | |
$ gcc -shared -fPIC -o test.so test.c | |
*/ | |
typedef int (*fn)(void); | |
int call_callback(fn ptr) { | |
return (*ptr)(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment