crategus / cl-cffi-gtk

cl-cffi-gtk is a Lisp binding to the GTK+ 3 library.

Home Page:http://www.crategus.com/books/cl-cffi-gtk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wrong uses of with-foreign-object

aymeric-nb opened this issue · comments

Hi,

cairo-font-extents in cairo/cairo.text.lisp returns a (:struct cairo-font-extents-t) obtained from with-foreign-object.

However, according to with-foreign-object's documentation, the object created by it is not valid outside the scope of with-foreign-object, if I understand correctly.

Indeed, accessing a field of the returned structure leads to a crash at least under ECL on NetBSD/amd64.

Sorry for not providing any patch, but I don't see a way around this bug without changing the lisp API.
A workaround is to use directly cairo::%cairo-font-extents but as the name implies, this is suboptimal.

A quick look around shows there are other such uses in other functions, so if you confirm my analysis, I think you should audit all uses of with-foreign-object and similar macros.

Regards

There are many terrible things hidden here, due to the author's misunderstanding of GTK objects and their lifespan. Beware.