Subject: 23.0.60; X protocol error: BadFont

From: Stephen Berman <[email-masked]>
Date: Sat, 24 Jan 2009 14:17:35 +0100

When I start Emacs like this:

emacs -Q --daemon --eval "(setq default-frame-alist '((font-backend . \"xft\") (font . \"Dejavu Sans Mono-10\")))"                        

and then invoke

emacsclient -c

the frame that appears displays the font Dejavu Sans Mono-10 with
antialiasing.  This is the same result as starting Emacs like this:

emacs -Q -xrm 'Emacs.FontBackend: xft' -fn "Dejavu Sans Mono-10"

(exept that here there is no daemon; as I learned, the --daemon option
is incompatible with X11 options).

But when I start Emacs like this:

emacs -Q --eval "(setq default-frame-alist '((font-backend . \"xft\") (font . \"Dejavu Sans Mono-10\")))" &

which differs from the first invocation above only in lacking `--daemon'
and being backgrounded, the frame that appears has tiny illegible
characters, the shell beeps and prints this:

steve@escher:~> libxcb: WARNING! Program tries to lock an already locked connection,
        which indicates a programming error.
        There will be no further warnings about this issue.

and emacs consumes 100% of CPU and can only be killed with -9.  (If I
don't use `&', then the frame immediately closes and the Emacs process
is killed.)  I repeated this under gdb, following the etc/DEBUG
instructions for debugging X protocal errors, and got the backtrace
below:

steve@escher:~/lib/emacs-cvs-gtk/src> gdb ./emacs
GNU gdb (GDB; openSUSE 11.1) 6.8.50.20081120-cvs 
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.           
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"   
and "show warranty" for details.                                             
This GDB was configured as "i586-suse-linux".                                
For bug reporting instructions, please see:                                  
<http://bugs.opensuse.org/>...                                               
SIGINT is used by the debugger.                                              
Are you sure you want to change it? (y or n) [answered Y; input not from terminal]
DISPLAY = :0                                                                      
TERM = xterm-256color                                                             
Breakpoint 1 at 0x8123156: file /home/steve/cvsroot/emacs/src/emacs.c, line 428.  
Temporary breakpoint 2 at 0x813ff79: file /home/steve/cvsroot/emacs/src/sysdep.c, line 1146.                                                                            
(gdb) br x_error_quitter
Breakpoint 3 at 0x80e0956: file /home/steve/cvsroot/emacs/src/xterm.c, line 8032.
(gdb) run -Q -xrm "emacs.synchronous: true" --eval "(setq default-frame-alist '((font-backend . \"xft\") (font . \"Dejavu Sans Mono-10\")))"                            
Starting program: /Users/steve/lib/emacs-cvs-gtk/src/emacs -Q -xrm "emacs.synchronous: true" --eval "(setq default-frame-alist '((font-backend . \"xft\") (font . \"Dejavu Sans Mono-10\")))"                                                               
[Thread debugging using libthread_db enabled]                                       

Breakpoint 3, x_error_quitter (display=0x86d7000, error=0xbfffce88)
    at /home/steve/cvsroot/emacs/src/xterm.c:8032                  
8032      if (error->error_code == BadName)                        
(gdb) bt full                                                      
#0  x_error_quitter (display=0x86d7000, error=0xbfffce88)          
    at /home/steve/cvsroot/emacs/src/xterm.c:8032                  
        buf = "\364\337\031\267 \000\000\000\000\000\000\000\364\337\031\267\200\261\030\267\030\317\377\277\000\017\242\b\364\357\377\267\234\315\377\277\\.\v\267\320\315\377\277\367\231\376\267@\000\000\000\000\000\000\000\240um\b\340um\b@Ui\267\374\205m\b\344\205m\b\324um\b\200\256\377\267\0062\003g\a\004\000\000\220\0318\003;\000\000\000\364\255T\267\214\243T\267\310\316\377\277\000\000\000\000\000\000\000\000\001\000\000\000\270\002\000\000\000\000\000\000@Ui\267W\021U\267\024\003U\267t\331T\267\001\000\000\000\364\357\377\267\370Vi\267\0062\003g\244\316\377\277)\233\376\267\224\316\377\277t\331T\267\210\316\377\277\324\367\377\267\031\000\000\000\000\000\000\000\001\000\000\000"...                                                            
        buf1 = "\214\234t\b\004\000\000\000\270\000A\b\210\372w\b\030b9\b\001", '\0' <repeats 23 times>, "\377\377\377\377\000\000\000\000\000Wi\b$\326\377\277\300\000\000\000\300\000\000\000\300\000\000\000\300\000\000\000\341\332\000 4\212\216\b$\326\377\277\210\372w\bZ\000\000\000\210\271\215\b\000\000\000\000\000\000\000\000l\326\377\277Y\000\000\000\017", '\0' <repeats 11 times>, "Z\000\000\000Y\000\000\000\000Wi\bH\256\215\b \000\000\000\274\243\030\267\324um\b\364um\b \000\000\000\274\243\030\267\324um\b\364um\b\000\000\000\000\000\000\000\000\001\000\000\000\016\227*\267\000\000\000\000 \000\000\000\204\321\377\277X\000\000\000\000\000\000\000 \000"...    
#1  0x080e0a03 in x_error_handler (display=0x86d7000, error=0xbfffce88)             
    at /home/steve/cvsroot/emacs/src/xterm.c:7997                                   
No locals.                                                                          
#2  0xb7583259 in _XError () from /usr/lib/libX11.so.6                              
No symbol table info available.                                                     
#3  0xb758b258 in ?? () from /usr/lib/libX11.so.6                                   
No symbol table info available.                                                     
#4  0xb758b602 in _XReply () from /usr/lib/libX11.so.6                              
No symbol table info available.                                                     
#5  0xb757e9c7 in XSync () from /usr/lib/libX11.so.6                                
No symbol table info available.                                                     
#6  0xb757eb65 in ?? () from /usr/lib/libX11.so.6                                   
No symbol table info available.                                                     
#7  0xb757c77a in XSetFont () from /usr/lib/libX11.so.6                             
No symbol table info available.                                                     
#8  0x081e7197 in xfont_prepare_face (f=0x877fa88, face=0x88e5d70)                  
    at /home/steve/cvsroot/emacs/src/xfont.c:788                                    
No locals.                                                                          
#9  0x080d3f24 in prepare_face_for_display (f=0x877fa88, face=0x88e5d70)            
    at /home/steve/cvsroot/emacs/src/xfaces.c:4314                                  
        xgcv = {                                                                    
  function = 0,                                                                     
  plane_mask = 0,                                                                   
  foreground = 0,                                                                   
  background = 12566463,                                                            
---Type <return> to continue, or q <return> to quit---                              
  line_width = 141389824,                                                           
  line_style = 0,                                                                   
  cap_style = -1217961996,                                                          
  join_style = 142106664,                                                           
  fill_style = -1220984512,                                                         
  fill_rule = -1073753928,                                                          
  arc_mode = 143630344,                                                             
  tile = 141389824,                                                                 
  stipple = 142106776,                                                              
  ts_x_origin = 240,                                                                
  ts_y_origin = 1,                                                                  
  font = 177537537,                                                                 
  subwindow_mode = 143446192,                                                       
  graphics_exposures = 0,                                                           
  clip_x_origin = 0,                                                                
  clip_y_origin = 4,                                                                
  clip_mask = 248,                                                                  
  dash_offset = 140737488,                                                          
  dashes = 112 'p'                                                                  
}                                                                                   
        mask = <value optimized out>                                                
#10 0x0806dacf in get_glyph_face_and_encoding (f=0x877fa88, glyph=0x89663b8,        
    char2b=0xbfffd140, two_byte_p=0xbfffd118)                                       
    at /home/steve/cvsroot/emacs/src/xdisp.c:19595                                  
        face = (struct face *) 0x88e5d70                                            
#11 0x0806db92 in fill_glyph_string (s=0xbfffd690, face_id=1,                       
    start=<value optimized out>, end=<value optimized out>, overlaps=0)             
    at /home/steve/cvsroot/emacs/src/xdisp.c:19752                                  
        two_byte_p = 0                                                              
        glyph = (struct glyph *) 0x89663b8                                          
        last = (struct glyph *) 0x896b7b8                                           
        voffset = 0                                                                 
        glyph_not_available_p = 0                                                   
#12 0x0806ec17 in draw_glyphs (w=0x856f8a0, x=0, row=0x88ef210, area=TEXT_AREA,     
    start=0, end=672, hl=DRAW_NORMAL_TEXT, overlaps=0)                              
    at /home/steve/cvsroot/emacs/src/xdisp.c:20368                                  
        first_glyph = <value optimized out>                                         
        head = (struct glyph_string *) 0xbfffd690                                   
        tail = (struct glyph_string *) 0x0                                          
        s = (struct glyph_string *) 0xbfffd690                                      
        clip_head = <value optimized out>                                           
        clip_tail = <value optimized out>                                           
        i = 0                                                                       
        j = <value optimized out>                                                   
---Type <return> to continue, or q <return> to quit---                              
        x_reached = <value optimized out>                                           
        last_x = 672                                                                
        area_left = 0                                                               
#13 0x08071571 in x_write_glyphs (start=0x89663b8, len=672)                         
    at /home/steve/cvsroot/emacs/src/xdisp.c:21932                                  
        x = <value optimized out>                                                   
#14 0x08057e0e in update_window_line (w=0x856f8a0, vpos=43,                         
    mouse_face_overwritten_p=0xbfffda7c)                                            
    at /home/steve/cvsroot/emacs/src/dispnew.c:4454                                 
        current_row = (struct glyph_row *) 0x88d50b8                                
        desired_row = (struct glyph_row *) 0x88ef210                                
        rif = (struct redisplay_interface *) 0x8209800                              
        changed_p = 0                                                               
#15 0x0805a597 in update_window (w=0x856f8a0, force_p=0)                            
    at /home/steve/cvsroot/emacs/src/dispnew.c:4253                                 
        end = (struct glyph_row *) 0x88ef210                                        
        header_line_row = (struct glyph_row *) 0x0                                  
        changed_p = <value optimized out>                                           
        mouse_face_overwritten_p = 0                                                
        row = (struct glyph_row *) 0x88ed888                                        
        yb = 600                                                                    
        desired_matrix = (struct glyph_matrix *) 0x8781600                          
        paused_p = 0                                                                
        rif = (struct redisplay_interface *) 0x8209800                              
#16 0x0805b6ca in update_window_tree (w=0x856f8a0, force_p=0)                       
    at /home/steve/cvsroot/emacs/src/dispnew.c:4003                                 
        paused_p = <value optimized out>                                            
#17 0x0805dc74 in update_frame (f=0x877fa88, force_p=0, inhibit_hairy_id_p=0)       
    at /home/steve/cvsroot/emacs/src/dispnew.c:3930                                 
        paused_p = <value optimized out>                                            
        root_window = (struct window *) 0x856f8a0                                   
#18 0x0808addb in redisplay_internal (preserve_echo_area=<value optimized out>)     
    at /home/steve/cvsroot/emacs/src/xdisp.c:11860                                  
        f = (struct frame *) 0x877fa88                                              
        tail = <value optimized out>                                                
        frame = <value optimized out>                                               
        w = (struct window *) 0x856f8a0                                             
        pause = 0                                                                   
        must_finish = 1                                                             
        number_of_visible_frames = 1                                                
        polling_stopped_here = 0                                                    
        old_frame = 142080652                                                       
        consider_all_windows_p = 1                                                  
#19 0x08130cb6 in read_char (commandflag=1, nmaps=2, maps=0xbfffe760,               
---Type <return> to continue, or q <return> to quit---                              
    prev_event=137952537, used_mouse_menu=0xbfffe814, end_time=0x0)                 
    at /home/steve/cvsroot/emacs/src/keyboard.c:2666                                
        c = <value optimized out>                                                   
        local_getcjmp = {{                                                          
    __jmpbuf = {-1073748432, 0, 137952537, 1, 140827365, -1},                       
    __mask_was_saved = -1073748388,                                                 
    __saved_mask = {                                                                
      __val = {137978392, 3221218888, 136165024, 140827365, 137981889, 1,           
        4294967295, 3221218908, 4294967295, 3221219112, 135838536, 140827365,       
        137981889, 137978396, 0 <repeats 18 times>}                                 
    }                                                                               
  }}                                                                                
        save_jump = {{                                                              
    __jmpbuf = {0, 0, 0, 0, 137978396, 0},                                          
    __mask_was_saved = 0,                                                           
    __saved_mask = {                                                                
      __val = {3221218712, 137978396, 0, 138794620, 3221218728, 136161287,          
        137978396, 138171281, 3221218760, 136162655, 137978396, 0, 191, 137978396,  
        0, 138794620, 3221218776, 136161287, 138171281, 137981889, 3221218808,      
        136162655, 137978396, 1, 190, 137981889, 140827360, 137952537, 3221218856,  
        136164843, 137981889, 140681397}                                            
    }                                                                               
  }}                                                                                
        key_already_recorded = 0                                                    
        tem = 0                                                                     
        save = <value optimized out>                                                
        previous_echo_area_message = 137952537                                      
        also_record = 137952537                                                     
        reread = 0                                                                  
        polling_stopped_here = <value optimized out>                                
        orig_kboard = (struct kboard *) 0x87168a0                                   
#20 0x08133041 in read_key_sequence (keybuf=0xbfffe8c4, bufsize=30,                 
    prompt=137952537, dont_downcase_last=0, can_return_switch_frame=1,              
    fix_current_buffer=1) at /home/steve/cvsroot/emacs/src/keyboard.c:9365          
        interrupted_kboard = (KBOARD *) 0x87168a0                                   
        key = 0                                                                     
        used_mouse_menu = 0                                                         
        echo_local_start = 0                                                        
        last_real_key_start = 0                                                     
        keys_local_start = 0                                                        
        local_first_binding = 0                                                     
        from_string = 137952537                                                     
        count = 2                                                                   
        t = 0                                                                       
---Type <return> to continue, or q <return> to quit---                              
        echo_start = 0                                                              
        keys_start = 0                                                              
        nmaps = 2                                                                   
        nmaps_allocated = 2                                                         
        defs = (Lisp_Object * volatile) 0xbfffe740                                  
        submaps = (Lisp_Object * volatile) 0xbfffe760                               
        orig_local_map = 140853581                                                  
        orig_keymap = 137952537                                                     
        localized_local_map = 0                                                     
        first_binding = 0                                                           
        first_unbound = 31                                                          
        mock_input = 0                                                              
        fkey = {                                                                    
  parent = 138559285,                                                               
  map = 138559285,                                                                  
  start = 0,                                                                        
  end = 0                                                                           
}                                                                                   
        keytran = {                                                                 
  parent = 137945981,                                                               
  map = 137945981,                                                                  
  start = 0,                                                                        
  end = 0                                                                           
}                                                                                   
        indec = {                                                                   
  parent = 138559349,                                                               
  map = 138559349,                                                                  
  start = 0,                                                                        
  end = 0                                                                           
}                                                                                   
        shift_translated = 0                                                        
        delayed_switch_frame = 137952537                                            
        original_uppercase = 2                                                      
        original_uppercase_position = -1                                            
        starting_buffer = (struct buffer *) 0x8396218                               
        fake_prefixed_keys = 137952537                                              
#21 0x08135164 in command_loop_1 ()                                                 
    at /home/steve/cvsroot/emacs/src/keyboard.c:1631                                
        cmd = <value optimized out>                                                 
        lose = <value optimized out>                                                
        nonundocount = 0                                                            
        keybuf = {-1073747702, -1073747736, 135460721, 140821005, 137952585,        
  -1073747702, 138887393, -1472036457, 137952537, -1073747640, 135461037,           
  140821005, -1073747702, 0, 0, 0, 1, 1012, -1224003832, 0, -1073747672,            
---Type <return> to continue, or q <return> to quit---                              
  -1073747824, 0, 0, 137952537, 138843497, 0, 138477768, 138477752, -1073747640}    
        i = <value optimized out>                                                   
        prev_modiff = 0                                                             
        prev_buffer = (struct buffer *) 0x0                                         
        already_adjusted = 0                                                        
#22 0x08191400 in internal_condition_case (bfun=0x8134f80 <command_loop_1>,         
    handlers=137995673, hfun=0x812f7e0 <cmd_error>)                                 
    at /home/steve/cvsroot/emacs/src/eval.c:1511                                    
        val = <value optimized out>                                                 
        c = {                                                                       
  tag = 137952537,                                                                  
  val = 137952537,                                                                  
  next = 0xbfffea70,                                                                
  gcpro = 0x0,                                                                      
  jmp = {{                                                                          
      __jmpbuf = {0, 138477768, 138477752, -1073747400, -1703495348, 1468242467},   
      __mask_was_saved = 0,                                                         
      __saved_mask = {                                                              
        __val = {3087005304, 134545392, 3070963464, 0, 0, 134544699, 3074771540,    
          3087003636, 3221219484, 3070963324, 3221219536, 3086916087, 0, 0, 1,      
          775, 3074771600, 3221220112, 3221219820, 3221220112, 3221219960,          
          135526276, 2, 3221219972, 3072601208, 3074771600, 4294967294,             
          4294967295, 3087003636, 3087005304, 134523852, 3221219904}                
      }                                                                             
    }},                                                                             
  backlist = 0x0,                                                                   
  handlerlist = 0x0,                                                                
  lisp_eval_depth = 0,                                                              
  pdlcount = 2,                                                                     
  poll_suppress_count = 1,                                                          
  interrupt_input_blocked = 0,                                                      
  byte_stack = 0x0                                                                  
}                                                                                   
        h = {                                                                       
  handler = 137995673,                                                              
  var = 137952537,                                                                  
  chosen_clause = 137952585,                                                        
  tag = 0xbfffe95c,                                                                 
  next = 0x0                                                                        
}                                                                                   
#23 0x0812ed25 in command_loop_2 ()                                                 
    at /home/steve/cvsroot/emacs/src/keyboard.c:1348                                
        val = 141389824                                                             
#24 0x081914da in internal_catch (tag=137991697, func=0x812ed00 <command_loop_2>,   
---Type <return> to continue, or q <return> to quit---                              
    arg=137952537) at /home/steve/cvsroot/emacs/src/eval.c:1247                     
        c = {                                                                       
  tag = 137991697,
  val = 137952537,
  next = 0x0,
  gcpro = 0x0,
  jmp = {{
      __jmpbuf = {0, 138477768, 138477752, -1073747144, -1703880372, 1468891683},
      __mask_was_saved = 0,
      __saved_mask = {
        __val = {0, 0, 0, 0, 0, 0, 3073021710, 0, 0, 0, 0, 0, 0, 0, 138252296,
          192, 0, 3073982840, 177, 22, 138191160, 138191586, 137978392,
          3221220136, 135801003, 138191161, 138191586, 137952537, 137978392,
          137952561, 138191584, 0}
      }
    }},
  backlist = 0x0,
  handlerlist = 0x0,
  lisp_eval_depth = 0,
  pdlcount = 2,
  poll_suppress_count = 1,
  interrupt_input_blocked = 0,
  byte_stack = 0x0
}
#25 0x0812f62f in command_loop () at /home/steve/cvsroot/emacs/src/keyboard.c:1327
No locals.
#26 0x0812f9bb in recursive_edit_1 ()
    at /home/steve/cvsroot/emacs/src/keyboard.c:942
        val = <value optimized out>
#27 0x0812fb04 in Frecursive_edit ()
    at /home/steve/cvsroot/emacs/src/keyboard.c:1004
        buffer = 137952537
#28 0x0812417f in main (argc=6, argv=0xbfffef44)
    at /home/steve/cvsroot/emacs/src/emacs.c:1786
        dummy = 139991912
        stack_bottom_variable = 8 '\b'
        do_initial_setlocale = 1
        skip_args = 0
        rlim = {
  rlim_cur = 8388608,
  rlim_max = 18446744073709551615
}
        no_loadup = 0
        junk = 0x0
---Type <return> to continue, or q <return> to quit---
        dname_arg = 0x0
(gdb)

In GNU Emacs 23.0.60.30 (i686-pc-linux-gnu, GTK+ Version 2.14.4)
 of 2009-01-21 on escher
Windowing system distributor `The X.Org Foundation', version 11.0.10502000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t