From: Hugo C. S. <hug...@gm...> - 2013-11-11 23:55:32
|
Hi! Just arrived to Common Lisp and SBCL I've installed cl-glfw3 bindings through quicklisp '(ql:quickload "cl-glfw3")' No problems here. Then I've loaded it through asdf "(asdf:oos 'asdf:load-op 'cl-glfw3)" It loads ok. Then I've tested some code, and I get SIGSEGVs. I've gone down till this code: (cl-glfw3:with-init (cl-glfw3:create-window :title "bleh bleh" :width 600 :height 400) (format t "test: ~A" glfw:*window*)) (cl-glfw3:with-init (cl-glfw3:create-window :title "bleh bleh" :width 600 :height 400) (format t "test: ~A" cl-glfw3:*window*)) Both return nil and print "test: #.(SB-SYS:INT-SAP #X00000000)" The related code in cl-glfw3.lisp is this >>>> (in-package #:glfw) (defvar *window* nil "The window that is currently the default for this library. Can be set through MAKE-CONTEXT-CURRENT.") (defun create-window ...not interesting... (let ((window (%glfw:create-window width height title monitor shared))) (if (eql (cffi:null-pointer) window) (error "Error creating window.") (make-context-current window)))) (defun make-context-current (window) (setf *window* window) (%glfw:make-context-current window)) <<<< If I use this test code it works: (cl-glfw3:with-init (let ((window (%glfw:create-window 600 400 "bleh bleh" (cffi:null-pointer) (cffi:null-pointer)))) (%glfw:make-context-current window) window)) And returns: #.(SB-SYS:INT-SAP #X7FFFE4048290) That is an equivalent form I think get executed by the first test code above. But just the last works. This works also: (cl-glfw3:with-init (let ((window (%glfw:create-window 600 400 "bleh bleh" (cffi:null-pointer) (cffi:null-pointer)))) (%glfw:make-context-current window) (setf cl-glfw3:*window* window) (loop until (cl-glfw3:window-should-close-p) do (cl-glfw3:swap-buffers) do (cl-glfw3:poll-events)))) So its ok for me for keep going. But gets a SIGSEGV if I use cl-glfw3:create-window. I've ran all code inside emacs and slime. Though the first code also breaks in console sbcl. I'm using SBCL 1.1.8-2.fc19 (Fedora) although I think the problem is in the library. I guess that *window* symbol inside cl-glfw3: is not getting assigned, but I can't figure why. Can anyone tell me why this happens? Any help appreciated. |
From: Andreas F. <and...@fr...> - 2013-11-24 19:39:01
|
On Tue, Nov 12, 2013 at 12:55 AM, Hugo Cienfuegos Suárez < hug...@gm...> wrote: > > Hi! > Just arrived to Common Lisp and SBCL > I've installed cl-glfw3 bindings through quicklisp '(ql:quickload "cl-glfw3")' No problems here. > Then I've loaded it through asdf "(asdf:oos 'asdf:load-op 'cl-glfw3)" It loads ok. > Then I've tested some code, and I get SIGSEGVs. > [...] > (defun create-window > ...not interesting... > (let ((window (%glfw:create-window width height title monitor shared))) > (if (eql (cffi:null-pointer) window) eql doesn't seem to be enough to detect equality here: > (eql (sb-sys:int-sap 0) (sb-sys:int-sap 0)) NIL > (sb-sys:sap= (cffi:null-pointer) (sb-sys:int-sap 0)) T So maybe try replacing the test expression with this: #-sbcl (eql (cffi:null-pointer) window) #+sbcl (and (sb-sys:system-area-pointer-p window) (sb-sys:sap= (cffi:null-pointer) window)) Cheers, Andreas |
From: Jeff C. <je...@jk...> - 2013-11-24 20:38:01
|
On 11/24/2013 11:33 AM, Andreas Franke wrote: > > On Tue, Nov 12, 2013 at 12:55 AM, Hugo Cienfuegos Suárez > <hug...@gm... <mailto:hug...@gm...>> wrote: > > > > Hi! > > Just arrived to Common Lisp and SBCL > > I've installed cl-glfw3 bindings through quicklisp '(ql:quickload > "cl-glfw3")' No problems here. > > Then I've loaded it through asdf "(asdf:oos 'asdf:load-op > 'cl-glfw3)" It loads ok. > > Then I've tested some code, and I get SIGSEGVs. > > [...] > > (defun create-window > > ...not interesting... > > (let ((window (%glfw:create-window width height title monitor > shared))) > > (if (eql (cffi:null-pointer) window) > > > eql doesn't seem to be enough to detect equality here: > > (eql (sb-sys:int-sap 0) (sb-sys:int-sap 0)) > NIL > > (sb-sys:sap= (cffi:null-pointer) (sb-sys:int-sap 0)) > T > > So maybe try replacing the test expression with this: > #-sbcl (eql (cffi:null-pointer) window) > #+sbcl (and (sb-sys:system-area-pointer-p window) > (sb-sys:sap= (cffi:null-pointer) window)) > > Cheers, > Andreas Try a stronger level of equality: equalp instead of eql. --Jeff |
From: Andreas F. <and...@fr...> - 2013-11-24 20:52:12
|
On Sun, Nov 24, 2013 at 9:11 PM, Jeff Cunningham <je...@jk...> wrote: > > On 11/24/2013 11:33 AM, Andreas Franke wrote: > > > On Tue, Nov 12, 2013 at 12:55 AM, Hugo Cienfuegos Suárez > <hug...@gm...> wrote: >> >> Hi! >> Just arrived to Common Lisp and SBCL >> I've installed cl-glfw3 bindings through quicklisp '(ql:quickload >> "cl-glfw3")' No problems here. >> Then I've loaded it through asdf "(asdf:oos 'asdf:load-op 'cl-glfw3)" It >> loads ok. >> Then I've tested some code, and I get SIGSEGVs. >> [...] >> (defun create-window >> ...not interesting... >> (let ((window (%glfw:create-window width height title monitor shared))) >> (if (eql (cffi:null-pointer) window) > > > eql doesn't seem to be enough to detect equality here: >> (eql (sb-sys:int-sap 0) (sb-sys:int-sap 0)) > NIL >> (sb-sys:sap= (cffi:null-pointer) (sb-sys:int-sap 0)) > T > > So maybe try replacing the test expression with this: > #-sbcl (eql (cffi:null-pointer) window) > #+sbcl (and (sb-sys:system-area-pointer-p window) > (sb-sys:sap= (cffi:null-pointer) window)) > > Cheers, > Andreas > > > Try a stronger level of equality: equalp instead of eql. Unfortunately, that doesn't help: > (equalp (sb-sys:int-sap 0) (sb-sys:int-sap 0)) NIL Cheers, Andreas > --Jeff |
From: Andreas F. <and...@fr...> - 2013-11-25 01:22:43
|
>> (let ((window (%glfw:create-window width height title monitor shared))) >> (if (eql (cffi:null-pointer) window) > #-sbcl (eql (cffi:null-pointer) window) > #+sbcl (and (sb-sys:system-area-pointer-p window) > (sb-sys:sap= (cffi:null-pointer) window)) Duh. It should be: (if (cffi:null-pointer-p window) ... :-) |
From: Hugo C. S. <hug...@gm...> - 2013-11-25 23:08:23
|
Wow, it looks odd that (eq (cffi:null-pointer) (cffi:null-pointer)) (eql (cffi:null-pointer) (cffi:null-pointer)) (equal (cffi:null-pointer) (cffi:null-pointer)) (equalp (cffi:null-pointer) (cffi:null-pointer)) All give NIL as result. Thanks, anyway, that's half of the problem, as %glfw:create-window returns a valid foreign pointer and cl-glfw3:create-window returns always a null pointer. 2013/11/25 Andreas Franke <and...@fr...> > >> (let ((window (%glfw:create-window width height title monitor > shared))) > >> (if (eql (cffi:null-pointer) window) > > > #-sbcl (eql (cffi:null-pointer) window) > > #+sbcl (and (sb-sys:system-area-pointer-p window) > > (sb-sys:sap= (cffi:null-pointer) window)) > > Duh. It should be: > (if (cffi:null-pointer-p window) > ... > > :-) > |
From: Stas B. <sta...@gm...> - 2013-11-26 08:34:49
|
Hugo Cienfuegos Suárez <hug...@gm...> writes: > Wow, it looks odd that > (eq (cffi:null-pointer) (cffi:null-pointer)) > (eql (cffi:null-pointer) (cffi:null-pointer)) > (equal (cffi:null-pointer) (cffi:null-pointer)) > (equalp (cffi:null-pointer) (cffi:null-pointer)) > All give NIL as result. Maybe I missed it in the previous replies, but wouldn't you want cffi:pointer-eq? -- With best regards, Stas. |
From: Hugo C. S. <hug...@gm...> - 2013-11-26 11:37:19
|
Both cffi:pointer-eq or cffi:null-pointer-p would do the trick, that's a bug in the code, but the problem comes by the fact that null is returned by the foreign call and it shouldn't. And when you do the same steps in the repl without relying on the high level interface it works as expected and no null is returned. In my former reply I just pointed to the shocking behaviour of all equality predicates in SBCL which always fail at comparing two null pointers. 2013/11/26 Stas Boukarev <sta...@gm...> > Hugo Cienfuegos Suárez <hug...@gm...> writes: > > > Wow, it looks odd that > > (eq (cffi:null-pointer) (cffi:null-pointer)) > > (eql (cffi:null-pointer) (cffi:null-pointer)) > > (equal (cffi:null-pointer) (cffi:null-pointer)) > > (equalp (cffi:null-pointer) (cffi:null-pointer)) > > All give NIL as result. > Maybe I missed it in the previous replies, but wouldn't you want > cffi:pointer-eq? > > -- > With best regards, Stas. > |