[cells-gtk-devel] Problems with demo
Peter Hildebrandt
peter.hildebrandt at gmail.com
Sat Feb 2 12:51:15 UTC 2008
Leandro,
sorry for the late reply. I've been busy over here.
Leandro Ríos wrote:
> Sorry for getting back late. I've been doing some debugging, and this is
> what I found so far:
>
> The error is raised in SBCL's %make-alien function, file
> target-alienval.lisp. More precisely:
>
> (defun %make-alien (bits)
> (declare (type index bits))
> (alien-funcall (extern-alien "malloc"
> (function system-area-pointer unsigned))
> (ash (the index (+ bits 7)) -3))) <<<<<<<<here
>
Alright, so the error actually occurs in one of SBCLs source files.
> This is the backtrace of the last debugging step before the error occurs:
>
> Evaluating call:
> (ASH (THE SB-INT:INDEX (+ SB-SYS:BITS 7)) -3)
> With unknown arguments
> Backtrace:
> 0: (CFFI:FOREIGN-ALLOC :INT)
> 1: (GTK-FFI:GTK-LIST-STORE-NEW (:STRING :STRING))
> 2: ((LAMBDA
> (CELLS::SLOT-C
> &AUX (CELLS:SELF (CELLS::C-MODEL CELLS::SLOT-C))
> (CELLS:.CACHE (CELLS::C-VALUE CELLS::SLOT-C))))
> [?#:<obs>=[0]ID/LIST-STORE])
Here is what list-store-new does:
(defun gtk-list-store-new (col-types)
(let ((c-types (cffi:foreign-alloc :int :count (length col-types))))
(loop for type in col-types
for n upfrom 0
do (setf (cffi:mem-aref c-types :int n) (coerce (as-gtk-type
type) 'integer)))
(prog1
(gtk-list-store-newv (length col-types) c-types)
(cffi:foreign-free c-types))))
So the call to foreign-alloc :int :count x is the first thing here.
That leads to this one (size is (* count (size-of :int))):
(defun %foreign-alloc (size)
"Allocate SIZE bytes on the heap and return a pointer."
(alien-sap (make-alien (unsigned 8) size)))
Which then goes to the step you had above.
> Next step, it hangs.
So AFAICT the problem really seems to be with sbcl's foreign function
interface. You are using the latest SBCL, right?
Maybe we should take this to their list.
> It seems that the problem originates in the call to
> (cells:md-slot-value list-store cells-gtk:new-args) only, calling the
> function with other parameters succeeds.
> I don't know enough about cffi or sbcl internals to determine if it is a
> malformed call from cffi or a bug in sbcl itself.
Me neither, so maybe you should go ahead and ask them.
> If you need me to perform any test you can think of, I'll be pleased to
> do so. Thanks for your help, Peter.
Great, thanks for your help. I do think your best bet is to ask in the
sbcl newsgroup or on their mailing list, though. You might find someone
on c.l.l, too, since the sbcl coders seem to be regulars there.
Cheers,
Peter
>
> Leandro
>
More information about the cells-gtk-devel
mailing list