Subject: Re: bug#18196: 24.4.50; crash when setting face background in terminal frame

From: Nicolas Avrutin <[email-masked]>
Date: Tue, 05 Aug 2014 12:34:36 -0400

On Tue, Aug 05 2014, martin rudalics <[email-masked]> wrote:
> Can you try the attached patch?

Your patch fixes this crash, however it introduces a new crash when
opening a new frame in emacs -nw. This crash is not present without your
patch.

In addition, I've also found another related issue that was present
before your patch, though it might be better suited for bug #18136.
After opening emacs -nw and resizing the terminal or creating a new
frame [C-x 5 2], the modeline moves down a line and overlaps the
echo area. It is then possible to get the modeline back up by either
closing all subsequent frames [C-x 5 0] or turning the menu bar off
and on [M-: (menu-bar-mode -1) RET M-: (menu-bar-mode 1) RET]

As for the crash:
Steps to reproduce (with your patch applied):
1. emacs -Q -nw
2. C-x 5 2

Backtrace:
(gdb) bt full
#0  terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=40) at emacs.c:359
No locals.
#1  0x00000000004f4ea8 in emacs_abort () at sysdep.c:2198
No locals.
#2  0x000000000049ea76 in cmcheckmagic (tty=0x6, tty@entry=0x13c6ce0) at cm.c:120
No locals.
#3  0x00000000004a4a6b in tty_write_glyphs (f=<optimized out>, string=0xcf81d0, len=<optimized out>) at term.c:802
        conversion_buffer = <optimized out>
        coding = 0x13c6a70
        n = <optimized out>
        stringlen = 0
        tty = 0x13c6ce0
#4  0x00000000004a6f0b in write_glyphs (f=f@entry=0x10dfaa0, string=string@entry=0xcf68b0, len=len@entry=134) at terminal.c:162
No locals.
#5  0x000000000041b01c in update_frame_line (f=f@entry=0x10dfaa0, vpos=vpos@entry=75) at dispnew.c:4854
        obody = 0x0
        nbody = 0xcf68b0
        op1 = <optimized out>
        op2 = <optimized out>
        np1 = <optimized out>
        nend = 0xcf81d0
        tem = <optimized out>
        osp = <optimized out>
        nsp = <optimized out>
        begmatch = <optimized out>
        endmatch = <optimized out>
        olen = 0
        nlen = 134
        current_matrix = <optimized out>
        desired_matrix = <optimized out>
        current_row = <optimized out>
        desired_row = <optimized out>
        must_write_whole_line_p = <optimized out>
        write_spaces_p = <optimized out>
        colored_spaces_p = false
#6  0x000000000041cb9a in update_frame_1 (f=f@entry=0x10dfaa0, force_p=force_p@entry=true, inhibit_id_p=<optimized out>, 
    inhibit_id_p@entry=false, set_cursor_p=set_cursor_p@entry=true) at dispnew.c:4541
        current_matrix = 0xc7cb70
        desired_matrix = 0x13ed3f0
        i = 75
        pause_p = <optimized out>
        preempt_count = 17
#7  0x000000000041dbf0 in update_frame (f=f@entry=0x10dfaa0, force_p=true, force_p@entry=false, 
    inhibit_hairy_id_p=inhibit_hairy_id_p@entry=false) at dispnew.c:3116
        paused_p = <optimized out>
#8  0x00000000004512c7 in redisplay_internal () at xdisp.c:13869
        gcscrollbars = <optimized out>
        w = <optimized out>
        sw = <optimized out>
        pending = <optimized out>
        must_finish = <optimized out>
        match_p = <optimized out>
        tlbufpos = <optimized out>
        tlendpos = <optimized out>
        number_of_visible_frames = <optimized out>
        polling_stopped_here = 1
        tail = 19721462
        consider_all_windows_p = <optimized out>
        update_miniwindow_p = <optimized out>
#9  0x0000000000451820 in redisplay () at xdisp.c:13115
No locals.
#10 0x00000000004e83bc in read_char (commandflag=1, map=map@entry=14224790, prev_event=12390578, 
    used_mouse_menu=used_mouse_menu@entry=0x7fffffffc25b, end_time=end_time@entry=0x0) at keyboard.c:2566
        echo_current = true
        c = <optimized out>
        jmpcount = <optimized out>
        local_getcjmp = {{
            __jmpbuf = {16752048, 5179720, 12390578, 0, 12417413, 12423154, 192, 0}, 
            __mask_was_saved = -16040, 
            __saved_mask = {
              __val = {12390578, 12390578, 16752054, 4, 2, 14224774, 4294967295, 12390578, 12390626, 12390578, 5181333, 19584758, 
                12390578, 17693349, 0, 12390578}
            }
          }}
        save_jump = {{
---Type <return> to continue, or q <return> to quit---
            __jmpbuf = {0, 140737352476816, 140737353742776, 4241052, 140737243393400, 4212872, 12390578, 20237522}, 
            __mask_was_saved = 20237522, 
            __saved_mask = {
              __val = {20237522, 12390578, 5, 12390578, 20237522, 12425333, 140737351932527, 3, 140733193388034, 5, 5488452, 
                12529426, 12417408, 2, 15884032, 16910658}
            }
          }}
        tem = <optimized out>
        save = <optimized out>
        previous_echo_area_message = 12390578
        also_record = 12390578
        reread = false
        polling_stopped_here = false
        orig_kboard = 0x13c92d0
#11 0x00000000004e99da in read_key_sequence (keybuf=keybuf@entry=0x7fffffffc320, bufsize=bufsize@entry=30, prompt=<optimized out>, 
    dont_downcase_last=dont_downcase_last@entry=false, can_return_switch_frame=can_return_switch_frame@entry=true, 
    fix_current_buffer=fix_current_buffer@entry=true, prevent_redisplay=false) at keyboard.c:9128
        interrupted_kboard = 0x13c92d0
        key = <optimized out>
        used_mouse_menu = false
        echo_local_start = 0
        last_real_key_start = 0
        keys_local_start = <optimized out>
        new_binding = <optimized out>
        t = 0
        echo_start = 0
        keys_start = 0
        current_binding = 14224790
        first_event = 12390578
        first_unbound = 31
        mock_input = 0
        fkey = {
          parent = 15725926, 
          map = 15725926, 
          start = 0, 
          end = 0
        }
        keytran = {
          parent = 12370502, 
          map = 12370502, 
          start = 0, 
          end = 0
        }
        indec = {
          parent = 15725942, 
          map = 15725942, 
          start = 0, 
          end = 0
        }
        shift_translated = false
        delayed_switch_frame = 12390578
        original_uppercase = 12514784
        original_uppercase_position = -1
        dummyflag = false
        starting_buffer = 0xbd7980
        fake_prefixed_keys = 12390578
#12 0x00000000004eb2e9 in command_loop_1 () at keyboard.c:1438
        cmd = <optimized out>
        keybuf = {96, 212, 200, 12390400, 0, 5470245, 140737488339968, 5535628, 12515824, 12390578, 12390578, 12390578, 20586736, 
          12390578, 0, 5470288, 12515826, 5470615, 12515824, 2, 12625046, 5533177, 0, 2, 15899862, 4000, 1, 0, 0, 5541319}
        i = <optimized out>
        prev_modiff = 10
        prev_buffer = 0xbd7980
#13 0x00000000005465a1 in internal_condition_case (bfun=bfun@entry=0x4eafed <command_loop_1>, handlers=12442482, 
    hfun=hfun@entry=0x4e2321 <cmd_error>) at eval.c:1347
        val = <optimized out>
        c = <optimized out>
#14 0x00000000004de2c3 in command_loop_2 (ignore=ignore@entry=12390578) at keyboard.c:1169
        val = <optimized out>
#15 0x0000000000546482 in internal_catch (tag=12438450, func=func@entry=0x4de2a9 <command_loop_2>, arg=12390578) at eval.c:1111
        val = <optimized out>
        c = <optimized out>
#16 0x00000000004de25b in command_loop () at keyboard.c:1148
No locals.
#17 0x00000000004e1f83 in recursive_edit_1 () at keyboard.c:769
---Type <return> to continue, or q <return> to quit---
        val = <optimized out>
#18 0x00000000004e2253 in Frecursive_edit () at keyboard.c:840
        buffer = <optimized out>
#19 0x00000000004ddd12 in main (argc=<optimized out>, argv=0x7fffffffc638) at emacs.c:1650
        dummy = 6031933
        stack_bottom_variable = 0 '\000'
        do_initial_setlocale = <optimized out>
        dumping = false
        skip_args = 1
        rlim = {
          rlim_cur = 8720000, 
          rlim_max = 18446744073709551615
        }
        no_loadup = false
        junk = 0x0
        dname_arg = 0x0
        ch_to_dir = 0x0
        original_pwd = 0x0

Lisp Backtrace:
"redisplay_internal (C function)" (0xb99298)

-- 
Nicolas Avrutin