Subject: Infinite loop noticed on Emacs in OpenBSD

From: Piotr Isajew <[email-masked]>
Date: Wed, 8 Nov 2017 19:00:42 +0100

Adding to the original report - I've noticed an issue which may
also relate to the same problem.

I'm using org-capture on OpenBSD under X11. M-x org-capture
displays a list of capture templates. On any other system I have
access to, or even on OpenBSD console, pressing a template letter
will open a capture buffer. On X11 however it hangs until I move
mouse. This was observed for Emacs 25 and 26 on OpenBSD
only. Additionally there are some situations when Emacs will just
hang in an infinite loop. There's no way to interrupt this, other
than SIGKILL.

I'm attaching stacktraces for such a situation:

info thre
  4 thread 424274  _thread_sys_poll () at -:3
  3 thread 437321  _thread_sys_poll () at -:3
* 2 thread 476142  _thread_sys_poll () at -:3
  1 thread 131181  wait_reading_process_output (time_limit=5, nsecs=0, 
    read_kbd=0, do_display=false, wait_for_cell=16374659, wait_proc=0x0, 
    just_wait_proc=0) at process.c:5296
(gdb) thr 4
[Switching to thread 4 (thread 424274)]#0  _thread_sys_poll () at -:3
3       in -
(gdb) inf sta
#0  _thread_sys_poll () at -:3
#1  0x00000002c6d1f45f in _libc_poll_cancel (fds=Variable "fds" is not available.
)
    at /usr/src/lib/libc/sys/w_poll.c:27
#2  0x000000022d883497 in g_main_context_iterate () at gmain.c:4271
#3  0x000000022d883594 in g_main_context_iteration (context=0x20ddb0500, 
    may_block=The value of variable 'may_block' is distributed across several
locations, and GDB cannot access its value.

) at gmain.c:4033
#4  0x00000002c7f2bb7d in g_io_module_query ()
   from /usr/local/lib/gio/modules/libdconfsettings.so
#5  0x000000022d8ac3fa in g_thread_proxy (data=0x259d50190) at gthread.c:784
#6  0x0000000275642cae in _rthread_start (v=Variable "v" is not available.
)
    at /usr/src/lib/librthread/rthread.c:96
#7  0x00000002c6d1b96b in __tfork_thread ()
    at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:75
#8  0x0000000000000000 in ?? ()

(gdb) thr 3
[Switching to thread 3 (thread 437321)]#0  _thread_sys_poll () at -:3
3       in -
(gdb) inf sta
#0  _thread_sys_poll () at -:3
#1  0x00000002c6d1f45f in _libc_poll_cancel (fds=Variable "fds" is not available.
)
    at /usr/src/lib/libc/sys/w_poll.c:27
#2  0x000000022d883497 in g_main_context_iterate () at gmain.c:4271
#3  0x000000022d883594 in g_main_context_iteration (context=0x243a3ce00, 
    may_block=The value of variable 'may_block' is distributed across several
locations, and GDB cannot access its value.

) at gmain.c:4033
#4  0x000000022d885296 in glib_worker_main (data=Variable "data" is not available.
) at gmain.c:5824
#5  0x000000022d8ac3fa in g_thread_proxy (data=0x259d50000) at gthread.c:784
#6  0x0000000275642cae in _rthread_start (v=Variable "v" is not available.
)
    at /usr/src/lib/librthread/rthread.c:96
#7  0x00000002c6d1b96b in __tfork_thread ()
    at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:75

(gdb) thr 2
[Switching to thread 2 (thread 476142)]#0  _thread_sys_poll () at -:3
3       in -
(gdb) inf sta
#0  _thread_sys_poll () at -:3
#1  0x00000002c6d1f45f in _libc_poll_cancel (fds=Variable "fds" is not available.
)
    at /usr/src/lib/libc/sys/w_poll.c:27
#2  0x000000022d883497 in g_main_context_iterate () at gmain.c:4271
#3  0x000000022d88382f in g_main_loop_run (loop=0x249a70a80) at gmain.c:4168
#4  0x00000002a5dac8cb in gdbus_shared_thread_func (user_data=0x2039baa80)
    at gdbusprivate.c:252
#5  0x000000022d8ac3fa in g_thread_proxy (data=0x27f39fed0) at gthread.c:784
#6  0x0000000275642cae in _rthread_start (v=Variable "v" is not available.
)
    at /usr/src/lib/librthread/rthread.c:96
#7  0x00000002c6d1b96b in __tfork_thread ()
    at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:75
#8  0x0000000000000000 in ?? ()

(gdb) thr 1
[Switching to thread 1 (thread 131181)]#0  wait_reading_process_output (
    time_limit=5, nsecs=0, read_kbd=0, do_display=false, 
    wait_for_cell=16374659, wait_proc=0x0, just_wait_proc=0) at process.c:5296
5296              FD_ZERO (&Available);
Current language:  auto; currently minimal
(gdb) inf sta
#0  wait_reading_process_output (time_limit=5, nsecs=0, read_kbd=0, 
    do_display=false, wait_for_cell=16374659, wait_proc=0x0, just_wait_proc=0)
    at process.c:5296
#1  0x00000000005b297d in x_get_foreign_selection (selection_symbol=9120, 
    target_type=240, time_stamp=0, frame=22101045) at xselect.c:1201
#2  0x00000000005b1f4c in Fx_get_selection_internal (selection_symbol=9120, 
    target_type=240, time_stamp=0, terminal=0) at xselect.c:2010
#3  0x00000000006fabf7 in funcall_subr (subr=0xbc8318, numargs=4, 
    args=0x7f7ffffdacd0) at eval.c:2849
#4  0x00000000006f983a in Ffuncall (nargs=5, args=0x7f7ffffdacc8)
    at eval.c:2766
#5  0x0000000000782f3d in exec_byte_code (bytestr=26624420, vector=20306061, 
    maxdepth=38, args_template=4106, nargs=2, args=0x7f7ffffdb798)
    at bytecode.c:629
#6  0x00000000006fafc5 in funcall_lambda (fun=23387365, nargs=2, 
    arg_vector=0x7f7ffffdb788) at eval.c:2967
#7  0x00000000006f9882 in Ffuncall (nargs=3, args=0x7f7ffffdb780)
    at eval.c:2768
#8  0x00000000006f961a in Fapply (nargs=2, args=0x7f7ffffdc0f0) at eval.c:2386
#9  0x00000000006faa86 in funcall_subr (subr=0xed78d8, numargs=2, 
    args=0x7f7ffffdc0f0) at eval.c:2821
#10 0x00000000006f983a in Ffuncall (nargs=3, args=0x7f7ffffdc0e8)
    at eval.c:2766
#11 0x0000000000782f3d in exec_byte_code (bytestr=22680196, vector=21880661, 
    maxdepth=62, args_template=514, nargs=2, args=0x7f7ffffdcc20)
    at bytecode.c:629
#12 0x00000000006fafc5 in funcall_lambda (fun=21811109, nargs=2, 
    arg_vector=0x7f7ffffdcc20) at eval.c:2967
#13 0x00000000006f9882 in Ffuncall (nargs=3, args=0x7f7ffffdcc18)
    at eval.c:2768
#14 0x0000000000782f3d in exec_byte_code (bytestr=13593108, vector=13593141, 
    maxdepth=38, args_template=2050, nargs=2, args=0x7f7ffffdd758)
    at bytecode.c:629
#15 0x00000000006fafc5 in funcall_lambda (fun=13593061, nargs=2, 
    arg_vector=0x7f7ffffdd748) at eval.c:2967
#16 0x00000000006f9882 in Ffuncall (nargs=3, args=0x7f7ffffdd740)
    at eval.c:2768
#17 0x0000000000782f3d in exec_byte_code (bytestr=11746807908, 
    vector=24821037, maxdepth=34, args_template=1030, nargs=1, 
    args=0x7f7ffffde348) at bytecode.c:629
#18 0x00000000006fafc5 in funcall_lambda (fun=24821173, nargs=1, 
    arg_vector=0x7f7ffffde340) at eval.c:2967
#19 0x00000000006f9882 in Ffuncall (nargs=2, args=0x7f7ffffde338)
    at eval.c:2768
#20 0x0000000000782f3d in exec_byte_code (bytestr=11743124740, 
    vector=11965495141, maxdepth=178, args_template=3074, nargs=0, 
    args=0x7f7ffffdf3e0) at bytecode.c:629
#21 0x00000000006fafc5 in funcall_lambda (fun=11965496357, nargs=0, 
    arg_vector=0x7f7ffffdf3e0) at eval.c:2967
#22 0x00000000006f9882 in Ffuncall (nargs=1, args=0x7f7ffffdf3d8)
    at eval.c:2768
#23 0x0000000000782f3d in exec_byte_code (bytestr=11904366884, 
    vector=9575961797, maxdepth=86, args_template=2050, nargs=1, 
    args=0x7f7ffffe01f8) at bytecode.c:629
#24 0x00000000006fafc5 in funcall_lambda (fun=9575962493, nargs=1, 
    arg_vector=0x7f7ffffe01f0) at eval.c:2967
#25 0x00000000006f9882 in Ffuncall (nargs=2, args=0x7f7ffffe01e8)
    at eval.c:2768
#26 0x00000000006daa3a in Ffuncall_interactively (nargs=2, args=0x7f7ffffe01e8)
    at callint.c:252
#27 0x00000000006faa86 in funcall_subr (subr=0xed7308, numargs=2, 
    args=0x7f7ffffe01e8) at eval.c:2821
#28 0x00000000006f983a in Ffuncall (nargs=3, args=0x7f7ffffe01e0)
    at eval.c:2766
#29 0x00000000006dd2bb in Fcall_interactively (function=7336368, 
    record_flag=0, keys=10242735877) at callint.c:841
#30 0x00000000006fabb9 in funcall_subr (subr=0xed72d8, numargs=3, 
    args=0x7f7ffffe0a20) at eval.c:2846
#31 0x00000000006f983a in Ffuncall (nargs=4, args=0x7f7ffffe0a18)
    at eval.c:2766
#32 0x0000000000782f3d in exec_byte_code (bytestr=13161172, vector=13161205, 
    maxdepth=54, args_template=4102, nargs=1, args=0x7f7ffffe15a8)
    at bytecode.c:629
#33 0x00000000006fafc5 in funcall_lambda (fun=13161125, nargs=1, 
    arg_vector=0x7f7ffffe15a0) at eval.c:2967
#34 0x00000000006f9882 in Ffuncall (nargs=2, args=0x7f7ffffe1598)
    at eval.c:2768
#35 0x00000000006fa3b2 in call1 (fn=15840, arg1=7336368) at eval.c:2617
#36 0x00000000005d67d7 in command_loop_1 () at keyboard.c:1482
#37 0x00000000006eaa57 in internal_condition_case (
    bfun=0x5d5e50 <command_loop_1>, handlers=20688, hfun=0x5ec220 <cmd_error>)
    at eval.c:1332
#38 0x00000000005ec122 in command_loop_2 (ignore=0) at keyboard.c:1110
#39 0x00000000006ea218 in internal_catch (tag=50256, 
    func=0x5ec0f0 <command_loop_2>, arg=0) at eval.c:1097
#40 0x00000000005d5414 in command_loop () at keyboard.c:1089
#41 0x00000000005d527c in recursive_edit_1 () at keyboard.c:695
#42 0x00000000005d559e in Frecursive_edit () at keyboard.c:766
#43 0x00000000005d301f in main (argc=1, argv=0x7f7ffffe1d78) at emacs.c:1713