Subject: bug#17125: Acknowledgement (24.4.50; daemon mode: closing X client frame exits entire emacs)

From: [email-masked] (Peder O. Klingenberg)
Date: Tue, 01 Apr 2014 13:35:24 +0200

The server process exits with a SIGSEGV and a core dump.  The error
seems to happen in font_clear_cache, maybe related to the changes
described in bug #16069

Attaching a gdb to the server process before starting the emacsclient
allowed me to capture the following:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000535f4e in PSEUDOVECTOR_TYPEP (a=0x7469672d73636168, code=15) at lisp.h:2378
2378      return ((a->size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK))
(gdb) bt full
#0  0x0000000000535f4e in PSEUDOVECTOR_TYPEP (a=0x7469672d73636168, code=15) at lisp.h:2378
No locals.
#1  0x0000000000535fbe in PSEUDOVECTORP (a=8388349225861341549, code=15) at lisp.h:2392
        h = 0x7469672d73636168
#2  0x00000000005e528d in font_clear_cache (f=0x1244b48, cache=16218886, driver=0xc219c0) at font.c:2604
        tail = 16211750
        elt = 12770162
        entity = 8388349225861341549
        i = 2175
#3  0x00000000005e5111 in font_finish_cache (f=0x1244b48, driver=0xc219c0) at font.c:2563
        cache = 16217926
        val = 16218726
        tmp = 16218902
#4  0x00000000005e7c87 in font_update_drivers (f=0x1244b48, new_drivers=12770162) at font.c:3472
        driver = 0xc219c0
        active_drivers = 12770162
        list = 0xece050
#5  0x0000000000423a92 in delete_frame (frame=19155789, force=12770162) at frame.c:1335
        f = 0x1244b48
        sf = 0xc41808
        kb = 0xc2db72
        minibuffer_selected = 0
        is_tooltip_frame = 0
#6  0x0000000000423fb7 in Fdelete_frame (frame=12770162, force=12770162) at frame.c:1509
No locals.
#7  0x00000000005d015d in Ffuncall (nargs=1, args=0x7fff937ae7a0) at eval.c:2818
        fun = 9305797
        original_fun = 12813026
        funcar = 140735667693392
        numargs = 0
        lisp_numargs = 2474305360
        val = 6099069
        internal_args = 0x7fff937ae6d0
        i = 2
#8  0x00000000005ca955 in Fcall_interactively (function=12813026, record_flag=12770162, keys=12804829) at callint.c:836
        val = 42949672960
        args = 0x7fff937ae7a0
        visargs = 0x7fff937ae780
        specs = 9339777
        filter_specs = 9339777
        teml = 42958978752
        up_event = 12770162
        enable = 12770162
        speccount = 5
        next_event = 3
        prefix_arg = 12770162
        string = 0x7fff937ae7c0 ""
        tem = 0x7fff937ae7c0 ""
        varies = 0x7fff937ae770 ""
        i = 1
        nargs = 1
        mark = 5463998
        arg_from_tty = false
        gcpro1 = {
          next = 0x0, 
          var = 0xa9c85d, 
          nvars = 140735667693744
        }
        gcpro2 = {
          next = 0x8, 
          var = 0xa9c8ad, 
          nvars = 140735667693792
        }
        gcpro3 = {
          next = 0x87, 
          var = 0xe06d9a47a6aa0200, 
          nvars = 1
        }
        gcpro4 = {
          next = 0x6, 
          var = 0x7fff937ae848, 
          nvars = 1
        }
        gcpro5 = {
          next = 0x7fff937ae460, 
          var = 0x0, 
          nvars = 11126960
        }
        key_count = 3
        record_then_fail = false
        save_this_command = 12813026
        save_last_command = 20548306
        save_this_original_command = 12813026
        save_real_this_command = 12813026
#9  0x00000000005d0190 in Ffuncall (nargs=4, args=0x7fff937aea98) at eval.c:2822
        fun = 12199085
        original_fun = 12946690
        funcar = 13065590
        numargs = 3
        lisp_numargs = 12809906
        val = 12770162
        internal_args = 0x7fff937aeaa0
        i = 2
#10 0x0000000000610808 in exec_byte_code (bytestr=10260337, vector=10260373, maxdepth=52, args_template=4100, nargs=1, args=0x7fff937af000) at bytecode.c:919
        targets = {0x613e3e, 0x613e9b, 0x613e9d, 0x613e9f, 0x613ea1, 0x613ea1, 0x613eff, 0x613f70, 0x6100dc, 0x6100de, 0x6100e0, 0x6100e2, 0x6100e4, 0x6100e4, 0x6100ea, 
          0x6100a1, 0x61052a, 0x61052c, 0x61052e, 0x610530, 0x610532, 0x610532, 0x610573, 0x610538, 0x610719, 0x61071b, 0x61071d, 0x61071f, 0x610721, 0x610721, 
          0x6106c1, 0x6106de, 0x6107d5, 0x6107d7, 0x6107d9, 0x6107db, 0x6107dd, 0x6107dd, 0x61077d, 0x61079a, 0x610898, 0x61089a, 0x61089c, 0x61089e, 0x6108a0, 
          0x6108a0, 0x610840, 0x61085d, 0x611905, 0x611632, 0x611629, 0x613e3e, 0x613e3e, 0x613e3e, 0x613e3e, 0x613e3e, 0x611b24, 0x611c0c, 0x611c63, 0x611cba, 
          0x611d15, 0x6103bc, 0x610427, 0x611d7f, 0x61031e, 0x61048b, 0x611dda, 0x611e3e, 0x611e85, 0x611ee9, 0x611f37, 0x612007, 0x61204e, 0x6120b2, 0x612130, 
          0x612177, 0x6121be, 0x612222, 0x612286, 0x6122ea, 0x612368, 0x6123b6, 0x612404, 0x6124d4, 0x612561, 0x6125ee, 0x61282a, 0x612893, 0x6128fc, 0x612965, 
          0x6129ce, 0x612a1c, 0x612aaa, 0x612af8, 0x612b46, 0x612b94, 0x612c94, 0x6114c2, 0x612cf5, 0x612d3c, 0x612e07, 0x612e68, 0x612ec9, 0x612f10, 0x612f60, 
          0x612fb0, 0x613008, 0x613e3e, 0x613059, 0x61309b, 0x6130dd, 0x61311f, 0x613161, 0x6131a3, 0x6114c2, 0x613e3e, 0x6131ea, 0x613239, 0x613280, 0x6132c7, 
          0x61332b, 0x61338f, 0x6133d6, 0x6134af, 0x613513, 0x613577, 0x6135db, 0x61361d, 0x613e3e, 0x6113fb, 0x61093c, 0x6101db, 0x610a58, 0x610b9b, 0x610cd5, 
          0x61138e, 0x6113c5, 0x61066f, 0x61147f, 0x6114f8, 0x611580, 0x6115c3, 0x611948, 0x6119c5, 0x611a43, 0x611aa8, 0x6108f5, 0x613664, 0x6136e2, 0x613729, 
          0x613770, 0x6137b7, 0x6137fe, 0x613862, 0x6138c6, 0x61392a, 0x61398e, 0x613abe, 0x613b22, 0x613b86, 0x613bcd, 0x613c31, 0x613c95, 0x613cea, 0x613d3f, 
          0x612be2, 0x612c30, 0x613d8d, 0x613de8, 0x613e3e, 0x610e0f, 0x610efe, 0x611026, 0x61114e, 0x61126e, 0x611f85, 0x612452, 0x612d85, 0x614005, 0x614076, 
          0x613e3e, 0x613e3e, 0x61410b, 0x613e3e, 0x613e3e, 0x613e3e, 0x613e3e, 0x613e3e, 0x613e3e, 0x613e3e, 0x613e3e, 0x613e3e, 0x614190 <repeats 64 times>}
        count = 4
        count_volatile = 51546406209
        op = 3
        vectorp = 0x9c8f98
        vectorp_volatile = 0x62a808
        stack = {
          pc = 0xb4c0a3 "\006\006\071\203\225", 
          byte_string = 10260337, 
          byte_string_start = 0xb4c035 "\305\020\211?\205\f", 
          next = 0x0
        }
        stack_volatile = {
          pc = 0x100c342f0 <Address 0x100c342f0 out of bounds>, 
          byte_string = 12796416, 
          byte_string_start = 0xc36ef2 "", 
          next = 0x130b796
        }
        top = 0x7fff937aea98
        result = 849472764
        type = 12
#11 0x00000000005d086f in funcall_lambda (fun=10260293, nargs=1, arg_vector=0x7fff937aeff8) at eval.c:2983
        val = 10260293
        syms_left = 4100
        next = 5463998
        lexenv = 140735667695384
        count = 4
        i = 51546072263
        optional = false
        rest = false
#12 0x00000000005d033c in Ffuncall (nargs=2, args=0x7fff937aeff0) at eval.c:2864
        fun = 10260293
        original_fun = 12813698
        funcar = 12619168
        numargs = 1
        lisp_numargs = 5
        val = 2
        internal_args = 0x7fff937af498
        i = 12770162
#13 0x00000000005cfae6 in call1 (fn=12813698, arg1=12813026) at eval.c:2614
        ret_ungc_val = 12770162
        gcpro1 = {
          next = 0x1, 
          var = 0x1301966, 
          nvars = 2
        }
        args = {12813698, 12813026}
#14 0x000000000053cee7 in command_loop_1 () at keyboard.c:1556
        scount = 2
        cmd = 12813026
        keybuf = {96, 212, 192, 5981058, 12619328, 12770162, 5463863, 12770162, 140735667695808, 5983251, 12770162, 12934418, 140735667695888, 5982183, 12619328, 
          12770162, 12934416, 20878576, 140735667695952, 6099650, 13053686, 2, 5, 12934416, 12619328, 140735667695888, 12770162, 17072050, 13053686, 9905253}
        i = 3
        prev_modiff = 11
        prev_buffer = 0xc342f0
        already_adjusted = false
#15 0x00000000005ccf95 in internal_condition_case (bfun=0x53c7f5 <command_loop_1>, handlers=12821410, hfun=0x53c0f8 <cmd_error>) at eval.c:1354
        val = 64
        c = 0x13dda30
#16 0x000000000053c54f in command_loop_2 (ignore=12770162) at keyboard.c:1174
        val = 140735667696792
#17 0x00000000005cc788 in internal_catch (tag=12817346, func=0x53c529 <command_loop_2>, arg=12770162) at eval.c:1118
        val = 12770162
        c = 0x13dd900
#18 0x000000000053c501 in command_loop () at keyboard.c:1153
No locals.
#19 0x000000000053bcf3 in recursive_edit_1 () at keyboard.c:777
        count = 1
        val = 12770162
#20 0x000000000053be60 in Frecursive_edit () at keyboard.c:845
        count = 0
        buffer = 12770162
#21 0x0000000000539f04 in main (argc=4, argv=0x7fff937af498) at emacs.c:1654
        dummy = 140285200712912
        stack_bottom_variable = 0 '\000'
        do_initial_setlocale = true
        dumping = false
        skip_args = 1
        rlim = {
          rlim_cur = 8720000, 
          rlim_max = 18446744073709551615
        }
        no_loadup = false
        junk = 0x0
        dname_arg = 0x7fff937b0870 "test"
        ch_to_dir = 0x689070 "H\211l$\330L\211d$\340H\215-\323J%"
        original_pwd = 0x0

Lisp Backtrace:
"delete-frame" (0x937ae7a8)
"call-interactively" (0x937aeaa0)
"command-execute" (0x937aeff8)

I poked around at different stuff, and this seemed somehow relevant:

(gdb) f 2
#2  0x00000000005e528d in font_clear_cache (f=0x1244b48, cache=16218886, driver=0xc219c0) at font.c:2604
2604                  if (FONT_ENTITY_P (entity)
(gdb) p elt
$14 = 12770162
(gdb) xpr
Lisp_Symbol
$15 = (struct Lisp_Symbol *) 0xc2db70
"nil"

I also evaluated (frame-font-cache) in both the error case and when I
started started the server with -Q (which, if you recall, means emacs
does not segfault at the first delete-frame).

-Q:
(frame-font-cache)
(":0" (x 1) (xft 1))

--no-site-file --no-init-file:
(frame-font-cache)
(":0" (x 1 (#<font-spec x misc fixed ## iso8859-1 nil nil nil nil nil 110 nil ((user-spec . "7x13"))> . [#<font-entity x misc fixed ## iso8859-1 medium r semicondensed 13 75 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium r semicondensed 13 100 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium r semicondensed 12 100 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium r semicondensed 12 75 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 9 75 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 9 100 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 8 75 110 50 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 8 100 110 50 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 7 75 110 50 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 7 100 110 50 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 6 75 110 40 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 20 75 110 100 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 20 100 110 100 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 18 100 110 90 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 15 75 110 90 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 15 100 110 90 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 14 75 110 70 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 14 100 110 70 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 13 75 110 80 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 13 75 110 70 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 13 100 110 80 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 13 100 110 70 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 10 100 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium r normal 10 75 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium o semicondensed 13 75 110 60 nil> #<font-entity x misc fixed ## iso8859-1 medium o normal 13 75 110 80 nil> #<font-entity x misc fixed ## iso8859-1 medium o normal 13 75 110 70 nil> #<font-entity x misc fixed ## iso8859-1 bold r semicondensed 13 75 110 60 nil> #<font-entity x misc fixed ## iso8859-1 bold r semicondensed 13 100 110 60 nil> #<font-entity x misc fixed ## iso8859-1 bold r normal 18 100 110 90 nil> #<font-entity x misc fixed ## iso8859-1 bold r normal 15 75 110 90 nil> #<font-entity x misc fixed ## iso8859-1 bold r normal 15 100 110 90 nil> #<font-entity x misc fixed ## iso8859-1 bold r normal 14 75 110 70 nil> #<font-entity x misc fixed ## iso8859-1 bold r normal 13 75 110 80 nil> #<font-entity x misc fixed ## iso8859-1 bold r normal 13 75 110 70 nil> #<font-entity x misc fixed ## iso8859-1 bold r normal 13 100 110 80 nil> #<font-entity x misc fixed ## iso8859-1 bold r normal 13 100 110 70 nil>]) (#<font-spec x nil 7x13 nil nil normal normal normal nil nil nil nil ((:name . "7x13"))> . #<font-entity x Misc Fixed ## ISO8859-1 medium r normal 13 75 110 70 nil>)) (xft 1 (#<font-spec xft misc fixed ## iso8859-1 nil nil nil nil nil 110 nil ((user-spec . "7x13"))> . []) (#<font-spec xft nil 7x13 nil nil normal normal normal nil nil nil nil ((:name . "7x13"))>) (#<font-spec xft nil Monospace nil iso8859-1 nil nil nil nil nil nil nil ((:name . "Monospace 10"))> . [#<font-entity xft bitstream Bitstream\ Vera\ Sans\ Mono nil iso10646-1 bold oblique normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMoBI.ttf" . 0) (:name . "Monospace 10"))> #<font-entity xft bitstream Bitstream\ Vera\ Sans\ Mono nil iso10646-1 normal normal normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf" . 0) (:name . "Monospace 10"))> #<font-entity xft bitstream Bitstream\ Vera\ Sans\ Mono nil iso10646-1 normal oblique normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMoIt.ttf" . 0) (:name . "Monospace 10"))> #<font-entity xft bitstream Bitstream\ Vera\ Sans\ Mono nil iso10646-1 bold normal normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMoBd.ttf" . 0) (:name . "Monospace 10"))>])))

Looking at the local i in stack frame #2 above, it seems way out of
bounds at 2175.