Subject: Re: bug#12327: Signal-handler cleanup for Emacs

From: Andy Moreton <[email-masked]>
Date: Thu, 06 Sep 2012 12:59:47 +0100

On Tue 04 Sep 2012, Paul Eggert wrote:

> On 09/03/2012 02:17 AM, Andreas Schwab wrote:
>> But that's really part of the signal->sigaction move.
>
> OK, I looked into that, and several other places are also
> affected by the move.  Attached is a patch to fix the issue
> that you found, and the other related issues that I saw.  This
> assumes the patch I already sent in <http://bugs.gnu.org/12327#20>.

This patch set (or something similar) was committed in r109893, and
causes a crash in the Windows build (r109892 is ok).

Crash is in r109893 built on Windows XP using MingGW gcc 4.6.2.

To reproduce it, run "M-x rgrep" using Cygwin grep. The grep
output is all displayed in the *grep* buffer, and then emacs aborts.

Attaching gdb gives the output below.

(gdb) thread apply all bt full

Thread 6 (Thread 2072.0x9fc):
#0  0x7c90e514 in ntdll!LdrAccessResource () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#1  0x7c90d9da in ntdll!ZwReadFile () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#2  0x7c801879 in ReadFile () from C:\WINDOWS\system32\kernel32.dll
No symbol table info available.
#3  0x00000628 in ?? ()
No symbol table info available.
#4  0x00000000 in ?? ()
No symbol table info available.

Thread 5 (Thread 2072.0xdfc):
#0  0x7c90e514 in ntdll!LdrAccessResource () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#1  0x7c90da4a in ntdll!ZwRemoveIoCompletion () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#2  0x7c80a7e6 in KERNEL32!GetQueuedCompletionStatus () from C:\WINDOWS\system32\kernel32.dll
No symbol table info available.
#3  0x77e7715c in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#4  0x77e772a0 in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#5  0x77e77328 in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#6  0x77e76ad1 in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#7  0x77e76c97 in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#8  0x7c80b729 in KERNEL32!GetModuleFileNameA () from C:\WINDOWS\system32\kernel32.dll
No symbol table info available.
#9  0x00000000 in ?? ()
No symbol table info available.

Thread 4 (Thread 2072.0x358):
#0  0x7c90e514 in ntdll!LdrAccessResource () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#1  0x7c90da4a in ntdll!ZwRemoveIoCompletion () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#2  0x7c80a7e6 in KERNEL32!GetQueuedCompletionStatus () from C:\WINDOWS\system32\kernel32.dll
No symbol table info available.
#3  0x77e7715c in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#4  0x77e772a0 in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#5  0x77e77328 in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#6  0x77e76ad1 in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#7  0x77e76c97 in RPCRT4!I_RpcBindingCopy () from C:\WINDOWS\system32\rpcrt4.dll
No symbol table info available.
#8  0x7c80b729 in KERNEL32!GetModuleFileNameA () from C:\WINDOWS\system32\kernel32.dll
No symbol table info available.
#9  0x00000000 in ?? ()
No symbol table info available.

Thread 3 (Thread 2072.0x1dc):
#0  0x7c90e514 in ntdll!LdrAccessResource () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#1  0x7c90df5a in ntdll!ZwWaitForSingleObject () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#2  0x7c8025db in WaitForSingleObjectEx () from C:\WINDOWS\system32\kernel32.dll
No symbol table info available.
#3  0x00000620 in ?? ()
No symbol table info available.
#4  0x00000000 in ?? ()
No symbol table info available.

Thread 2 (Thread 2072.0x410):
#0  0x7c90e514 in ntdll!LdrAccessResource () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#1  0x77f16bf2 in GdiDrawStream () from C:\WINDOWS\system32\gdi32.dll
No symbol table info available.
#2  0x00fa2b1b in ?? () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#3  0x00fa289b in ?? () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#4  0x00fa2753 in ?? () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#5  0x00fa2c9f in UxTheme!DrawThemeParentBackground () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#6  0x00fa5f42 in UxTheme!SetThemeAppProperties () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#7  0x00fa6485 in UxTheme!SetThemeAppProperties () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#8  0x00fbc4b9 in UxTheme!GetThemeTextMetrics () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#9  0x00fa1ac7 in ?? () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#10 0x00fa1b3d in ?? () from C:\WINDOWS\system32\uxtheme.dll
No symbol table info available.
#11 0x7e4294ed in USER32!GetPropW () from C:\WINDOWS\system32\user32.dll
No symbol table info available.
#12 0x0114b954 in w32_wnd_proc (hwnd=0xa036c, msg=0x85, wParam=0x870409db, lParam=0x0) at w32fns.c:3832
        f = 0xa45740
        dpyinfo = 0x16626c0
        wmsg = {
          msg = {
            hwnd = 0x12,
            message = 0x7240f7c8,
            wParam = 0xfc505d,
            lParam = 0xfbe152,
            time = 0xfbe535,
            pt = {
              x = 0x7240f838,
              y = 0x6
            }
          },
          dwModifiers = 0x6,
          rect = {
            left = 0x11,
            top = 0x11,
            right = 0x7240f87c,
            bottom = 0x11
          }
        }
        windows_translate = 0xfa39d6
        key = 0xa45740
#13 0x7e418734 in USER32!GetDC () from C:\WINDOWS\system32\user32.dll
No symbol table info available.
#14 0x000a036c in ?? ()
No symbol table info available.
#15 0x00000085 in ?? ()
No symbol table info available.
#16 0x870409db in ?? ()
No symbol table info available.
#17 0x00000000 in ?? ()
No symbol table info available.

Thread 1 (Thread 2072.0x564):
#0  0x7c90120f in ntdll!DbgUiConnectToDbg () from C:\WINDOWS\system32\ntdll.dll
No symbol table info available.
#1  0x0115317e in emacs_abort () at w32fns.c:7215
        button = 0x6
#2  0x010539f2 in sys_wait (status=0x82f264) at w32proc.c:462
        active = 0x0
        retval = 0x0
        nh = 0x0
        pid = 0xc38
        cp = 0x165f430
        cps = {0x165f430, 0x82f1d8, 0x82f490, 0x82fcdc, 0x1, 0x8, 0x353c81a, 0x0, 0x82f23c, 0x132c256, 0x60, 0x0, 0x82f99c, 0x82f3e8, 0x10e02e4, 0x5, 0x7c90df4a, 0x7c809590, 0x7ffdf000, 0x82f280, 0x7c8095d2, 0x82f22c, 0x7c8095c0, 0x0, 0x8, 0x0, 0x714, 0x710, 0x68c, 0x644, 0x5fc, 0x600}
        wait_hnd = {0x0, 0x82f168, 0x1028d66, 0x3555ad2, 0x353c832, 0x82f1d8, 0x1036669, 0x13f203d, 0x3, 0x132c24e, 0x353c81a, 0x163a5e8, 0x82f15c, 0x82fcdc, 0x3555ad0, 0x353c81a, 0x82fcf0, 0x82f1d8, 0x10380e2, 0x3555ad2, 0x353c832, 0x0, 0x82f12c, 0x10320ff, 0x82ffe0, 0x0, 0x3555ad2, 0x353c832, 0x0, 0x0, 0x3, 0x35554aa}
#3  0x010508a0 in record_child_status_change () at process.c:6422
        proc = 0x534cee5
        p = 0x534cee0
        pid = 0xc38
        w = 0x0
        tail = 0x536717e
#4  0x01050ee0 in handle_child_signal (sig=0x12) at process.c:6529
No locals.
#5  0x01143cfe in handle_on_main_thread (sig=0x12, handler=0x1050ed1 <handle_child_signal>) at sysdep.c:1584
        old_errno = 0x16
        on_main_thread = 0x1
#6  0x01050eff in deliver_child_signal (sig=0x12) at process.c:6536
No locals.
#7  0x01054d67 in sys_select (nfds=0xa, rfds=0x82f6e4, wfds=0x0, efds=0x0, timeout=0x82f6d4, ignored=0x0) at w32proc.c:1325
        orfds = {
          bits = {0x309, 0x0}
        }
        timeout_ms = 0xfa
        start_time = 0x5e2323e
        i = 0xa
        nh = 0x5
        nc = 0x2
        nr = 0x1
        active = 0x5
        cp = 0x165f430
        cps = {0x165f430, 0x165f3d8, 0x82f5bc, 0xee6b280, 0x0, 0xee6b280, 0x30, 0x0 <repeats 17 times>, 0xa, 0x200, 0x82f628, 0x1014eea, 0x0, 0x0, 0x0, 0x353c81a}
        wait_hnd = {0x714, 0x710, 0x68c, 0x644, 0x5fc, 0x600, 0x624, 0x82f5bc, 0x1, 0x82f5e8, 0x82f598, 0x12c0b6b, 0x82f4e8, 0x0, 0x850000, 0x0, 0x1645970, 0x86a4d0, 0x850000, 0x1028d66, 0x15ad2, 0x8, 0x82f3d4, 0x850000, 0x82f4c8, 0xe11f, 0x82f4b8, 0x105917e, 0x50488ca1, 0x36d61600, 0x82f4d8, 0x1103595, 0x50488ca1, 0x36d61600, 0x29e, 0x1, 0x82f99c, 0x3c8c90c, 0x82f4e8, 0x5048, 0x0, 0xe09c0, 0x8ca1, 0x5048, 0x7c80a0e9, 0x0, 0x82f518, 0x100dd13, 0x0, 0xee6b280, 0xee6b280, 0xee6b280, 0x50488ca1, 0xe11f, 0x82f528, 0x105917e, 0x50488ca1, 0x36d61600, 0x82f548, 0x1103595, 0x50488ca1, 0x36d61600, 0x29e, 0xce70001, 0xfbe96c7a, 0x1cd8c24, 0x82f558, 0x5048, 0x0, 0xe09c0, 0x8ca1, 0x5048, 0x0, 0x0, 0x82f588, 0x100dd13, 0x0, 0xee6b280, 0xee6b280, 0x1662720, 0x16626c0, 0x0, 0x82f588, 0x1142a8d, 0x50488ca1, 0x36d61600, 0x0, 0x0, 0xa, 0x1, 0x0, 0x3811de0, 0x1, 0x82f5e8, 0x82f608, 0x10150ed}
        fdindex = {0xffffffff, 0x0, 0x3, 0x8, 0x9, 0x353c81a, 0x82f378, 0x1028c3b, 0x163a414, 0x353c81a, 0x0, 0x0, 0x163a414, 0x82f380, 0x82f378, 0x1028a1c, 0x3546de2, 0x457c7c0, 0x353c81a, 0x38e4226, 0x391e1ca, 0x0, 0x82f418, 0x10362be, 0x3546de2, 0x353c81a, 0x392284a, 0x39229ca, 0x4bbf405, 0x54184be, 0x82f438, 0x36f1e8a, 0x353c802, 0x82f4a4, 0x26aaec7a, 0x77c49210, 0x26aaec7a, 0x2fda46, 0x989680, 0x0, 0x200, 0x1, 0x77c4921d, 0xce7e2a0, 0xfbe96c7a, 0x1cd8c24, 0x86a508, 0x7c90cfea, 0x7c80a0e9, 0x710, 0x82f438, 0x7c90cfea, 0x7c80a0e9, 0x710, 0x82f448, 0x12e5c9c, 0x16627bc, 0x353c81a, 0x4405800, 0x353c81a, 0x36f1e8a, 0x82f514, 0x26aaec7a, 0x77c49210}
#8  0x0104ca1f in wait_reading_process_output (time_limit=0x23, nsecs=0x0, read_kbd=0xffffffff, do_display=0x1, wait_for_cell=0x353c81a, wait_proc=0x0, just_wait_proc=0x0) at process.c:4682
        timeout_reduced_for_timers = 0x1
        channel = 0xa
        nfds = 0x1
        Available = {
          bits = {0x200, 0x0}
        }
        Writeok = {
          bits = {0x0, 0x0}
        }
        check_write = 0x0
        check_delay = 0x0
        no_avail = 0x0
        xerrno = 0x16
        proc = 0x534cee5
        timeout = {
          tv_sec = 0x0,
          tv_nsec = 0x0
        }
        end_time = {
          tv_sec = 0x50488cc4,
          tv_nsec = 0x26fb3f80
        }
        wait_channel = 0xffffffff
        got_some_input = 0x1
        count = 0x2
#9  0x010faab4 in sit_for (timeout=0x8c, reading=0x1, do_display=0x1) at dispnew.c:5972
        sec = 0x23
        nsec = 0x0
#10 0x01009478 in read_char (commandflag=0x1, nmaps=0x5, maps=0x82f990, prev_event=0x353c81a, used_mouse_menu=0x82fa78, end_time=0x0) at keyboard.c:2742
        tem0 = 0x82f938
        timeout = 0x23
        delay_level = 0x5
        buffer_size = 0x3f
        c = 0x353c81a
        jmpcount = 0x2
        local_getcjmp = {0x82f938, 0x3c8c900, 0x82f99c, 0x3c8c90c, 0x82f7bc, 0x1008d63, 0x82ffe0, 0x0, 0x82f8e8, 0x378e1ca, 0x3565f02, 0x3c8c900, 0x82f8c8, 0x1027b11, 0x379e540, 0x379e540}
        save_jump = {0x0 <repeats 16 times>}
        key_already_recorded = 0x0
        tem = 0x3cf79ee
        save = 0xdb15
        previous_echo_area_message = 0x353c81a
        also_record = 0x353c81a
        reread = 0x0
        gcpro1 = {
          next = 0x12e3542,
          var = 0x51e2276,
          nvars = 0x354377a
        }
        gcpro2 = {
          next = 0x82f830,
          var = 0x354377a,
          nvars = 0x82f828
        }
        polling_stopped_here = 0x0
        orig_kboard = 0x353f500
#11 0x0101c9ae in read_key_sequence (keybuf=0x82fc00, bufsize=0x1e, prompt=0x353c81a, dont_downcase_last=0x0, can_return_switch_frame=0x1, fix_current_buffer=0x1) at keyboard.c:9356
        interrupted_kboard = 0x353f500
        interrupted_frame = 0x3811de0
        key = 0x4405805
        used_mouse_menu = 0x0
        echo_local_start = 0x0
        last_real_key_start = 0x0
        keys_local_start = 0x0
        local_first_binding = 0x0
        from_string = 0x353c81a
        count = 0x2
        t = 0x0
        echo_start = 0x0
        keys_start = 0x0
        nmaps = 0x5
        nmaps_allocated = 0x5
        defs = 0x82f960
        submaps = 0x82f990
        orig_local_map = 0x4247c76
        orig_keymap = 0x353c81a
        localized_local_map = 0x0
        first_binding = 0x0
        first_unbound = 0x1f
        mock_input = 0x0
        fkey = {
          parent = 0x38f7456,
          map = 0x38f7456,
          start = 0x0,
          end = 0x0
        }
        keytran = {
          parent = 0x3539ec6,
          map = 0x3539ec6,
          start = 0x0,
          end = 0x0
        }
        indec = {
          parent = 0x38f745e,
          map = 0x38f745e,
          start = 0x0,
          end = 0x0
        }
        shift_translated = 0x0
        delayed_switch_frame = 0x353c81a
        original_uppercase = 0x36c50
        original_uppercase_position = 0xffffffff
        dummyflag = 0x0
        starting_buffer = 0x4405800
        fake_prefixed_keys = 0x353c81a
        gcpro1 = {
          next = 0x4405800,
          var = 0x44c0668,
          nvars = 0x82fac8
        }
#12 0x01005e1b in command_loop_1 () at keyboard.c:1499
        cmd = 0x3565f02
        keybuf = {0x200001e0, 0x353c81a, 0x82fb00, 0x0, 0x163a630, 0x353c81a, 0x3745dfa, 0x35554aa, 0x353c81a, 0x0, 0x0, 0x35554a8, 0x0, 0x0, 0x82fc68, 0x1037cfb, 0x35554aa, 0x353c81a, 0x44f6b7e, 0x353c81a, 0xc, 0x353c81a, 0x2, 0x7ffd6000, 0x0, 0x0, 0x82fc98, 0x1033c91, 0x2, 0x44f6b7e}
        i = 0x1
        prev_modiff = 0x1dd
        prev_buffer = 0x4405800
        already_adjusted = 0x0
#13 0x01032285 in internal_condition_case (bfun=0x1005929 <command_loop_1>, handlers=0x3548dca, hfun=0x10050fe <cmd_error>) at eval.c:1319
        val = 0x44f6b7e
        c = {
          tag = 0x353c81a,
          val = 0x353c81a,
          next = 0x82fda4,
          gcpro = 0x0,
          jmp = {0x82fd68, 0x7ffd6000, 0x0, 0x0, 0x82fcbc, 0x1032232, 0x82ffe0, 0x0, 0x2, 0x0, 0x82fdd0, 0x2, 0x2, 0x0, 0x1, 0x1},
          backlist = 0x0,
          handlerlist = 0x0,
          lisp_eval_depth = 0x0,
          pdlcount = 0x2,
          poll_suppress_count = 0x0,
          interrupt_input_blocked = 0x0,
          byte_stack = 0x0
        }
        h = {
          handler = 0x3548dca,
          var = 0x353c81a,
          chosen_clause = 0x2020e99,
          tag = 0x82fcf0,
          next = 0x0
        }
#14 0x01005556 in command_loop_2 (ignore=0x353c81a) at keyboard.c:1194
        val = 0x7ffd6000
#15 0x01031c96 in internal_catch (tag=0x3546612, func=0x1005532 <command_loop_2>, arg=0x353c81a) at eval.c:1076
        c = {
          tag = 0x3546612,
          val = 0x353c81a,
          next = 0x0,
          gcpro = 0x0,
          jmp = {0x82fe18, 0x7ffd6000, 0x0, 0x0, 0x82fd8c, 0x1031c87, 0x82ffe0, 0x0, 0x353c81a, 0x3542e00, 0x740053, 0x6e0061, 0x7ffd6000, 0x82fe18, 0x1027b01, 0x165c4fc},
          backlist = 0x0,
          handlerlist = 0x0,
          lisp_eval_depth = 0x0,
          pdlcount = 0x2,
          poll_suppress_count = 0x0,
          interrupt_input_blocked = 0x0,
          byte_stack = 0x0
        }
#16 0x01005512 in command_loop () at keyboard.c:1173
No locals.
#17 0x01004abb in recursive_edit_1 () at keyboard.c:794
        count = 0x1
        val = 0x77c4a190
#18 0x01004de8 in Frecursive_edit () at keyboard.c:858
        count = 0x0
        buffer = 0x353c81a
#19 0x01002abc in main (argc=0x2, argv=0xa425b0) at emacs.c:1643
        dummy = 0x82ffe0
        stack_bottom_variable = 0x0
        do_initial_setlocale = 0x1
        skip_args = 0x0
        no_loadup = 0x0
        junk = 0x0
        dname_arg = 0x0
        ch_to_dir = 0x0
(gdb) quit