Subject: Re: bug#22214: 25.0.50; lock up with gui dialogs and clipmon-mode

From: Joseph Mingrone <[email-masked]>
Date: Mon, 21 Dec 2015 15:42:57 -0400

Eli Zaretskii <[email-masked]> writes:

>> From: Joseph Mingrone <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Mon, 21 Dec 2015 12:41:47 -0400

>> Thread 3 (Thread 1902400 (LWP 100743)):
>> #0  0x0000000807444cfa in _sigprocmask () from /lib/libc.so.7
>> #1  0x0000000804656526 in pthread_sigmask () from /lib/libthr.so.3
>> #2  0x00000000007ab8e9 in block_atimers (oldset=0x7fffffff7970) at atimer.c:70
>> #3  0x00000000007abffc in do_pending_atimers () at atimer.c:434
>> #4  0x00000000005f803e in process_pending_signals () at keyboard.c:7043
>> #5  0x00000000006c1559 in Fmake_list (length=0, init=0) at alloc.c:2718
>> #6  0x0000000000713c2a in concat (nargs=1, args=0x7fffffff7b28, target_type=Lisp_Cons, last_special=false) at fns.c:633
>> #7  0x00000000007135d2 in Fcopy_sequence (arg=18186131) at fns.c:501
>> #8  0x00000000005f25b3 in timer_check () at keyboard.c:4452

> Thanks.

> Can you find out which thread uses up the CPU?  If that's this thread
> (the Emacs application main thread), can you use the technique
> described in etc/DEBUG under "If the symptom of the bug is that Emacs
> fails to respond" to find out whether Emacs is looping and where?

It looks like it's looping in process.c  starting at line 4565

  while (1)
    {
      bool process_skipped = false;
      ...

The gdb output below shows the steps through the looping.

Joseph

jrm@phe ~/scm/nm/emacs.git/src % /usr/local/bin/gdb ./emacs
GNU gdb (GDB) 7.10 [GDB v7.10 for FreeBSD]
Copyright (C) 2015 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 "x86_64-portbld-freebsd10.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./emacs...done.
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.0
TERM = screen-256color
Breakpoint 1 at 0x5dfb54: file emacs.c, line 371.
Temporary breakpoint 2 at 0x61e9d9: file sysdep.c, line 905.
(gdb) run -Q
Starting program: /usr/home/jrm/scm/nm/emacs.git/src/emacs -Q
[New Thread 1902400 (LWP 101016)]
^Z[New Thread 16b5c00 (LWP 100130)]

Program received signal SIGTSTP, Stopped (user).
[Switching to Thread 1902400 (LWP 101016)]
0x000000080736efaa in ktimer_settime () from /lib/libc.so.7
(gdb) finish
Run till exit from #0  0x000000080736efaa in ktimer_settime () from /lib/libc.so.7
0x00000000007abd8b in set_alarm () at atimer.c:312
312                   && timer_settime (alarm_timer, TIMER_ABSTIME, &ispec, 0) == 0)
(gdb) finish
Run till exit from #0  0x00000000007abd8b in set_alarm () at atimer.c:312
run_timers () at atimer.c:382
382     }
(gdb) finish
Run till exit from #0  run_timers () at atimer.c:382
do_pending_atimers () at atimer.c:436
436           unblock_atimers (&oldset);
(gdb) finish
Run till exit from #0  do_pending_atimers () at atimer.c:436
process_pending_signals () at keyboard.c:7044
7044    }
(gdb) finish
Run till exit from #0  process_pending_signals () at keyboard.c:7044
Fmake_list (length=0, init=0) at alloc.c:2689
2689      while (size > 0)
(gdb) finish
Run till exit from #0  Fmake_list (length=0, init=0) at alloc.c:2689
0x0000000000713c2a in concat (nargs=1, args=0x7fffffff7ad8, target_type=Lisp_Cons, last_special=false) at fns.c:633
633         val = Fmake_list (make_number (result_len), Qnil);
Value returned is $1 = 105189203
(gdb) finish
Run till exit from #0  0x0000000000713c2a in concat (nargs=1, args=0x7fffffff7ad8, target_type=Lisp_Cons, last_special=false)
    at fns.c:633
Fcopy_sequence (arg=21640739) at fns.c:502
502     }
Value returned is $2 = 105189203
(gdb) finish
Run till exit from #0  Fcopy_sequence (arg=21640739) at fns.c:502
0x00000000005f25b3 in timer_check () at keyboard.c:4452
4452      timers = Fcopy_sequence (Vtimer_list);
Value returned is $3 = 105189203
(gdb) finish
Run till exit from #0  0x00000000005f25b3 in timer_check () at keyboard.c:4452
readable_events (flags=1) at keyboard.c:3313
3313      if (kbd_fetch_ptr != kbd_store_ptr)
Value returned is $4 = {tv_sec = 0, tv_nsec = -1}
(gdb) finish
Run till exit from #0  readable_events (flags=1) at keyboard.c:3313
0x00000000005f7963 in get_input_pending (flags=1) at keyboard.c:6691
6691      input_pending = (!NILP (Vquit_flag) || readable_events (flags));
Value returned is $5 = true
(gdb) finish
Run till exit from #0  0x00000000005f7963 in get_input_pending (flags=1) at keyboard.c:6691
swallow_events (do_display=false) at keyboard.c:4205
4205      if (!input_pending && timers_run != old_timers_run && do_display)
Value returned is $6 = true
(gdb) finish
Run till exit from #0  swallow_events (do_display=false) at keyboard.c:4205
wait_reading_process_output (time_limit=5, nsecs=0, read_kbd=0, do_display=false, wait_for_cell=17528851, wait_proc=0x0,
    just_wait_proc=0) at process.c:5004
5004          if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
(gdb) finish
Run till exit from #0  wait_reading_process_output (time_limit=5, nsecs=0, read_kbd=0, do_display=false, wait_for_cell=17528851,
    wait_proc=0x0, just_wait_proc=0) at process.c:5004
^Z
Program received signal SIGTSTP, Stopped (user).
0x000000080736efaa in ktimer_settime () from /lib/libc.so.7
(gdb) finish
Run till exit from #0  0x000000080736efaa in ktimer_settime () from /lib/libc.so.7
0x00000000007abd8b in set_alarm () at atimer.c:312
312                   && timer_settime (alarm_timer, TIMER_ABSTIME, &ispec, 0) == 0)
(gdb) finish
Run till exit from #0  0x00000000007abd8b in set_alarm () at atimer.c:312
run_timers () at atimer.c:382
382     }
(gdb) finish
Run till exit from #0  run_timers () at atimer.c:382
do_pending_atimers () at atimer.c:436
436           unblock_atimers (&oldset);
(gdb) finish
Run till exit from #0  do_pending_atimers () at atimer.c:436
process_pending_signals () at keyboard.c:7044
7044    }
(gdb) finish
Run till exit from #0  process_pending_signals () at keyboard.c:7044
0x0000000000788a69 in wait_reading_process_output (time_limit=5, nsecs=0, read_kbd=0, do_display=false, wait_for_cell=17528851,
    wait_proc=0x0, just_wait_proc=0) at process.c:4573
4573            QUIT;
(gdb) finish
Run till exit from #0  0x0000000000788a69 in wait_reading_process_output (time_limit=5, nsecs=0, read_kbd=0, do_display=false,
    wait_for_cell=17528851, wait_proc=0x0, just_wait_proc=0) at process.c:4573
^Z
Program received signal SIGTSTP, Stopped (user).
0x0000000807444cfa in _sigprocmask () from /lib/libc.so.7
(gdb) finish
Run till exit from #0  0x0000000807444cfa in _sigprocmask () from /lib/libc.so.7
0x0000000804656526 in pthread_sigmask () from /lib/libthr.so.3
(gdb) finish
Run till exit from #0  0x0000000804656526 in pthread_sigmask () from /lib/libthr.so.3
unblock_atimers (oldset=0x7fffffff7920) at atimer.c:76
76      }
(gdb) finish
Run till exit from #0  unblock_atimers (oldset=0x7fffffff7920) at atimer.c:76
do_pending_atimers () at atimer.c:438
438     }
(gdb) finish
Run till exit from #0  do_pending_atimers () at atimer.c:438
process_pending_signals () at keyboard.c:7044
7044    }
(gdb) finish
Run till exit from #0  process_pending_signals () at keyboard.c:7044
Fmake_list (length=0, init=0) at alloc.c:2689
2689      while (size > 0)
(gdb) finish
Run till exit from #0  Fmake_list (length=0, init=0) at alloc.c:2689
0x0000000000713c2a in concat (nargs=1, args=0x7fffffff7ad8, target_type=Lisp_Cons, last_special=false) at fns.c:633
633         val = Fmake_list (make_number (result_len), Qnil);
Value returned is $7 = 757173027
(gdb) finish
Run till exit from #0  0x0000000000713c2a in concat (nargs=1, args=0x7fffffff7ad8, target_type=Lisp_Cons, last_special=false)
    at fns.c:633
Fcopy_sequence (arg=21640739) at fns.c:502
502     }
Value returned is $8 = 757173027
(gdb) finish
Run till exit from #0  Fcopy_sequence (arg=21640739) at fns.c:502
0x00000000005f25b3 in timer_check () at keyboard.c:4452
4452      timers = Fcopy_sequence (Vtimer_list);
Value returned is $9 = 757173027
(gdb) finish
Run till exit from #0  0x00000000005f25b3 in timer_check () at keyboard.c:4452
readable_events (flags=1) at keyboard.c:3313
3313      if (kbd_fetch_ptr != kbd_store_ptr)
Value returned is $10 = {tv_sec = 0, tv_nsec = -1}
(gdb) finish
Run till exit from #0  readable_events (flags=1) at keyboard.c:3313
0x00000000005f7963 in get_input_pending (flags=1) at keyboard.c:6691
6691      input_pending = (!NILP (Vquit_flag) || readable_events (flags));
Value returned is $11 = true
(gdb) finish
Run till exit from #0  0x00000000005f7963 in get_input_pending (flags=1) at keyboard.c:6691
swallow_events (do_display=false) at keyboard.c:4205
4205      if (!input_pending && timers_run != old_timers_run && do_display)
Value returned is $12 = true
(gdb) finish
Run till exit from #0  swallow_events (do_display=false) at keyboard.c:4205
wait_reading_process_output (time_limit=5, nsecs=0, read_kbd=0, do_display=false, wait_for_cell=17528851, wait_proc=0x0,
    just_wait_proc=0) at process.c:5004
5004          if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
(gdb) next
5013          if (read_kbd && interrupt_input
(gdb) next
5020          if (read_kbd || ! NILP (wait_for_cell))
(gdb) next
5021            do_pending_window_change (0);
(gdb) next
5024          if (no_avail || nfds == 0)
(gdb) next
5025            continue;
(gdb) next
5215        }                           /* End while exit conditions not met.  */
(gdb) next
4567          bool process_skipped = false;
(gdb) next
4572          if (read_kbd >= 0)
(gdb) next
4573            QUIT;
(gdb) next
4578          if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
(gdb) next
4583          if (wait == TIMEOUT)
(gdb) next
4585              if (!timespec_valid_p (now))
(gdb) next
4587              if (timespec_cmp (end_time, now) <= 0)
(gdb) next
4589              timeout = timespec_sub (end_time, now);
(gdb) next
4598          if (NILP (wait_for_cell)
(gdb) next
4642          if (read_kbd < 0)
(gdb) next
4649          if (update_tick != process_tick)
(gdb) next
4681          if (wait_proc && wait_proc->raw_status_new)
(gdb) next
4683          if (wait_proc
(gdb) next
4727          if (wait_proc && just_wait_proc)
(gdb) next
4735          else if (!NILP (wait_for_cell))
(gdb) next
4737              Available = non_process_wait_mask;
(gdb) next
4738              check_delay = 0;
(gdb) next
4739              check_write = 0;
(gdb) next
4757          if (frame_garbaged && do_display)
(gdb) next
4769          no_avail = 0;
(gdb) next
4770          if ((read_kbd || !NILP (wait_for_cell))
(gdb) next
4771              && detect_input_pending ())
(gdb) next
4773              nfds = read_kbd ? 0 : 1;
(gdb) next
4774              no_avail = 1;
(gdb) next
4775              FD_ZERO (&Available);
(gdb) next
4910          xerrno = errno;
(gdb) next
4913          clear_waiting_for_input ();
(gdb) next
4916          do_pending_window_change (0);
(gdb) next
4918          if (nfds == 0)
(gdb) next
4942          if (nfds < 0)
(gdb) next
4956          if (read_kbd != 0)
(gdb) next
4983          if (read_kbd != 0
(gdb) next
4994          if (read_kbd == 0 && detect_input_pending ())
(gdb) next
4996              swallow_events (do_display);
(gdb) next
5004          if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
(gdb) next
5013          if (read_kbd && interrupt_input
(gdb) next
5020          if (read_kbd || ! NILP (wait_for_cell))
(gdb) next
5021            do_pending_window_change (0);
(gdb) next
5024          if (no_avail || nfds == 0)
(gdb) next
5025            continue;
(gdb) next
5215        }                           /* End while exit conditions not met.  */
(gdb)