this-console-appender "resolves" its stream, obtaining an fd-stream, at initialization time. In SBCL, such a fd-stream becomes invalid after image save/restart. Using such an invalid fd-stream can lead to "Bad file descriptor" errors:
$ sbcl --noinform --no-userinit \
--load ~/.local/share/common-lisp/quicklisp/setup.lisp \
--eval '(ql:quickload :log4cl)' \
--eval '(defun f () (log:info "bla"))' \
--eval '(save-lisp-and-die "bla" :executable t :toplevel (quote f))'
[...]
$ ./bla
<INFO> [15:22:07] cl-user (f) - bla
ERROR - Caught SB-INT:SIMPLE-STREAM-ERROR
Couldn't write to #<SB-SYS:FD-STREAM for "the terminal" {1000247223}>:
Bad file descriptor
Removing #<LOG4CL-IMPL:TRICKY-CONSOLE-APPENDER {10023EA193}>
from #<LOGGER +ROOT+ {1000630413}>
and even memory corruption.
This patch extends init-hook to re-resolve this-console-appender streams and adds logging of errors to init/save/exit hooks.
Reading the diff, I now realize a mistake: in call-with-logged-problems, the warning case has an incorrect format string: it should be "~S" instead of "configuration" like in the error case. Sorry.
this-console-appender
"resolves" its stream, obtaining anfd-stream
, at initialization time. In SBCL, such afd-stream
becomes invalid after image save/restart. Using such an invalidfd-stream
can lead to "Bad file descriptor" errors:and even memory corruption.
This patch extends
init-hook
to re-resolvethis-console-appender
streams and adds logging of errors to init/save/exit hooks.