Deadlock with PCL global mutex in log-func
Currently, forms passed to (log:* ...) are wrapped in log-func and called while Log4CL serialized appender lock is being held. This is prone to deadlock because such forms are user code and may (attempt to) acquire other locks. In particular, this can cause deadlock with PCL global mutex on SBCL when redefining classes.
In principle this can be fixed by moving the call to log-func outside Log4CL serialized appender lock. I'm not sure how difficult it is given how the code is structured, but at least I think documenting it here may help others encountering the same issue.
Thank you for the report.
I couldn't find a reliable way to demonstrate the issue with idiomatic code but this at least does it:
(let (i)
(defclass bar () ())
(defclass foo () ())
(setf i (make-instance 'bar))
(defmethod shared-initialize :after ((instance foo) (slot-names t) &key) (sleep 2) (log:info "a"))
(sb-thread:make-thread (lambda () (change-class i 'foo)))
(log:info (defclass bar () ())))
I will look into the suggested fix a bit.