crategus / cl-cffi-gtk

cl-cffi-gtk is a Lisp binding to the GTK+ 3 library.
http://www.crategus.com/books/cl-cffi-gtk
145 stars 33 forks source link

gtk/gtk.main-loop.lisp Package Locks #83

Closed anranyicheng closed 3 years ago

anranyicheng commented 3 years ago

Hello, When I load :gtk-demo, I caught an error, my envirment is Ubuntu20.04 + sbcl 2.0.11 + slime +emacs26.3: Code: CL-USER> (ql:quickload :gtk-demo) To load "gtk-demo": Load 1 ASDF system: gtk-demo ; Loading "gtk-demo" ; ; caught ERROR: ; READ error during COMPILE-FILE: ;
; Lock on package SB-UNIX violated when interning SIGPIPE-HANDLER while in ; package GTK. ; See also: ; The SBCL Manual, Node "Package Locks" ;
; (in form starting at line: 223, column: 0, position: 8690)

I found the Bug :

(defun %gtk-init() ...... ......

+(and sbcl (not win32))

(sb-unix::enable-interrupt sb-unix:sigpipe #'sb-unix::sigpipe-handler) ..... .....)

Any one can help me? Thanks!

ghost commented 3 years ago

here is a tutorial on the Internet http://www.crategus.com/books/cl-gtk/gtk-tutorial.html#Getting_started

;There is no package called gdk-demo in quicklisp,
;you need to load the entire cl-cffi-gtk package, not a part of it,

;Happy Winter Solstice

(ql:quickload :cl-cffi-gtk)
;To load "cl-cffi-gtk":
;  Load 1 ASDF system:
;    cl-cffi-gtk
; Loading "cl-cffi-gtk"
;.................
;(:CL-CFFI-GTK)

(defpackage :gtk-tutorial
    (:use :gtk :gdk :gdk-pixbuf :gobject
     :glib :gio :pango :cairo :common-lisp))
;#<PACKAGE "GTK-TUTORIAL">

(in-package :gtk-tutorial)
;#<PACKAGE "GTK-TUTORIAL">

(defun example-simple-window ()
  (within-main-loop
    (let (;; Create a toplevel window.
          (window (gtk-window-new :toplevel)))
      ;; Signal handler for the window to handle the signal "destroy".
      (g-signal-connect window "destroy"
                        (lambda (widget)
                          (declare (ignore widget))
                          (leave-gtk-main)))
      ;; Show the window.
      (gtk-widget-show-all window))))
;EXAMPLE-SIMPLE-WINDOW

(example-simple-window)
;#<SB-THREAD:THREAD "cl-cffi-gtk main thread" RUNNING {10027AFDD3}>
;1
anranyicheng commented 3 years ago

I got it. but the code is different between quicklisp and github.
function (defun %gtk-init()....) in https://github.com/Ferada/cl-cffi-gtk/blob/master/gtk/gtk.main-loop.lisp
is not the same as https://github.com/crategus/cl-cffi-gtk/blob/master/gtk/gtk.main-loop.lisp.

+(and sbcl (not win32))

(sb-unix::enable-interrupt sb-unix:sigpipe #'sb-unix::sigpipe-handler)

+(and sbcl (not win32))

(let ((handler (find-symbol (string '#:sigpipe-handler) (string '#:sb-unix))) (enable (find-symbol (string '#:enable-interrupt) (string '#:sb-unix))) (signal (find-symbol (string '#:sigpipe) (string '#:sb-unix)))) (when handler (funcall enable (symbol-value signal) (symbol-function handler))))

anranyicheng commented 3 years ago

https://github.com/Ferada/cl-cffi-gtk/commit/63c0c8c4dbd6012deb4b63d0b25783cde63f71a7

ghost commented 3 years ago

I don’t understand the code, sorry

;;; ----------------------------------------------------------------------------
;;; gtk_init ()
;;; ----------------------------------------------------------------------------

;;; TODO: The function is for internal use and not exported.
;;; Rework the handling of command line parameters in this function and
;;; the function %gtk-init-check.

(defun %gtk-init ()
mjkalyan commented 3 years ago

Forgive my ignorance but why is this closed? It appears to still be an issue for me. Are we expected to patch the source with the Ferada version?

stacksmith commented 3 years ago

Just happened to me, on a clean install of everything: sbcl, quicklisp.;

; caught ERROR:
;   READ error during COMPILE-FILE:
;   
;     Lock on package SB-UNIX violated when interning SIGPIPE-HANDLER while in
;     package GTK.
;   See also:
;     The SBCL Manual, Node "Package Locks"
;   
;     (in form starting at line: 167, column: 0, position: 6703)

The symbol in question appears to be SIGPIPE

stacksmith commented 3 years ago

Lots of googling... No answers. Removed the entire form that causes the problem, by substituting #+nil:

#+nil;(and sbcl (not win32))
  (sb-unix::enable-interrupt sb-unix:sigpipe #'sb-unix::sigpipe-handler)

So far no problems.

debuhr commented 11 months ago

@stacksmith The same problem happened to me when using (ql:quickload ...) simultanously from portacle and the command line (e.g. having a makefile to create an executable while also editing in portacle) which may make sense in the context of package locks. You could try exiting other sbcl instances which are using quicklisp.

anranyicheng commented 10 months ago

@stacksmith The same problem happened to me when using (ql:quickload ...) simultanously from portacle and the command line (e.g. having a makefile to create an executable while also editing in portacle) which may make sense in the context of package locks. You could try exiting other sbcl instances which are using quicklisp.

bug already fixed: https://github.com/crategus/cl-cffi-gtk/commit/ffe2301a67c1fb42d1ecb99428bc834948d80410 so download the library and put it into /quicklisp/local-projects/ do not download and install from quicklisp