7max / log4cl

Common Lisp logging framework, modeled after Log4J
Apache License 2.0
103 stars 32 forks source link

Re-resolve streams of THIS-CONSOLE-APPENDER instances in INIT-HOOK #19

Closed scymtym closed 11 years ago

scymtym commented 11 years ago

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.

scymtym commented 11 years ago

Thanks.

scymtym commented 11 years ago

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.