Subject: Re: bug#13289: 24.2; bookmark didn't save when using emacsclient

From: Chong Yidong <[email-masked]>
Date: Sat, 19 Jan 2013 00:24:17 +0800

Glenn Morris <[email-masked]> writes:

> It seems that bookmark-write-file fails to return from:
>
> (dolist (i bookmark-alist) (pp i (current-buffer)))
>
> pp-buffer dies someway through trying to process something like this:
>
>   ("README" (filename . "/misc/emacs/bzr/emacs24/README")
> (front-context-string . "Copyright (C) 20") (rear-context-string)
> (position . 1))
>
> I don't know why.

The reason is the following.  The above call to `pp' contains a call to
`scan-lists' which is enclosed in `ignore-errors'.  Normally, the error
is caught and `pp' goes on to do its job.  However, because the hook is
being run while Emacs is in a sigterm handler waiting to die (so that
waiting_for_input is true), the Fsignal aborts Emacs instead of
signalling a Lisp error:

Program received signal SIGABRT, Aborted.
0x00007ffff1fc40bb in raise () from /usr/lib/libpthread.so.0
(gdb) bt
#0  0x00007ffff1fc40bb in raise () from /usr/lib/libpthread.so.0
#1  0x0000000000536b79 in terminate_due_to_signal (sig=6, backtrace_limit=
    40) at emacs.c:342
#2  0x000000000055b8d4 in emacs_abort () at sysdep.c:2152
#3  0x00000000005d3ab2 in Fsignal (error_symbol=12920114, data=19830086)
    at eval.c:1370
#4  0x00000000005d3df7 in xsignal (error_symbol=12920114, data=19830086)
    at eval.c:1466
#5  0x00000000005d3ec6 in xsignal3 (error_symbol=12920114, arg1=15034017, 
    arg2=196, arg3=200) at eval.c:1493
#6  0x0000000000612d6b in scan_lists (from=196, count=1, depth=-2, 
    sexpflag=0) at syntax.c:2614
#7  0x0000000000615a82 in Fscan_lists (from=60, count=4, depth=-4)
    at syntax.c:2877
#8  0x00000000005d674d in Ffuncall (nargs=4, args=0x7fffffff9698)
    at eval.c:2682
...
#36 0x00000000005d5b7c in Frun_hooks (nargs=1, args=0x7fffffffc0e8)
    at eval.c:2248
#37 0x0000000000538cb4 in Fkill_emacs (arg=60) at emacs.c:1852
#38 0x0000000000536b12 in terminate_due_to_signal (sig=15, backtrace_limit=
    40) at emacs.c:324
#39 0x000000000055b390 in handle_fatal_signal (sig=15) at sysdep.c:1653
...
Lisp Backtrace:
"scan-lists" (0xffff96a0)
"down-list" (0xffff9b90)
"byte-code" (0xffff9f90)
"pp-buffer" (0xffffa770)
"pp-to-string" (0xffffac58)
"pp" (0xffffb130)
"bookmark-write-file" (0xffffb620)
"bookmark-save" (0xffffbb00)
"bookmark-exit-hook-internal" (0xffffc0b8)