В процессе написания биндингов к gtksourceview столкнулся со странной проблемой.
Загрузим в SBCL кусок кода:
(in-package :gtk)
(load-foreign-library "libgtksourceview-2.0.so")
(define-g-object-class "GtkSourceLanguageManager" source-language-manager
(:export t :interfaces
())
())
(defcfun gtk-source-language-manager-get-language-ids
:pointer
(language-manager (g-object source-language-manager)))
(defun get-language-list (language-manager)
(let ((pointer (gtk-source-language-manager-get-language-ids language-manager)))
(loop with i = 0
until (null-pointer-p (mem-aref pointer :pointer i))
collect (mem-aref pointer :string i)
do (incf i))))
теперь можно заметить, что код
(setq *lm* (make-instance 'source-language-manager))
(get-language-list *lm*)
(make-instance 'source-language-manager)
(get-language-list *)
* (make-instance 'source-language-manager)
(<unknown>:4278): GLib-GObject-CRITICAL **: g_object_newv: assertion `G_TYPE_IS_OBJECT (object_type)' failed
(<unknown>:4278): GLib-GObject-CRITICAL **: g_object_add_toggle_ref: assertion `G_IS_OBJECT (object)' failed
(<unknown>:4278): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
#<SOURCE-LANGUAGE-MANAGER {C587AB9}>
* (get-language-list *)
(<unknown>:4278): GtkSourceView-CRITICAL **: gtk_source_language_manager_get_language_ids: assertion `GTK_IS_SOURCE_LANGUAGE_MANAGER (lm)' failed
CORRUPTION WARNING in SBCL pid 4278(tid 3085097760):
Memory fault at 0 (pc=0xc52a6f5, sp=0xb7985ba8)
The integrity of this image is possibly compromised.
Continuing with fingers crossed.
debugger invoked on a SB-SYS:MEMORY-FAULT-ERROR in thread #<THREAD "initial thread" RUNNING {BECF659}>:
Unhandled memory fault at #x0.
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(SB-SYS:MEMORY-FAULT-ERROR)
0]