Subject: Re: bug#75056: 31.0.50; tty-child-frames with server / multiple clients possible hangs

From: Gerd Möllmann <[email-masked]>
Date: Fri, 27 Dec 2024 14:17:11 +0100

Eli Zaretskii <[email-masked]> writes:

> But I'm not yet sure this is what we see in this case, which is why I
> asked for a C backtrace.  Producing it should be easy: just reproduce
> the problem, then attach a debugger and produce the backtrace.

See below. AFAICS, Emacs is waiting for input, and when we have some,
the wrong things will happen. Please note that this is not a full debug
build.

bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  frame #0: 0x0000000190be51a8 libsystem_kernel.dylib`__pselect + 8
  frame #1: 0x0000000190be5080 libsystem_kernel.dylib`pselect$DARWIN_EXTSN + 64
    frame #2: 0x00000001047181d4 emacs`really_call_select(arg=0x000000016b8d44e0) at thread.c:620:16 [opt]
    frame #3: 0x0000000104718148 emacs`thread_select [inlined] flush_stack_call_func(func=<unavailable>, arg=0x000000016b8d44e0) at lisp.h:4842:3 [opt]
    frame #4: 0x0000000104718138 emacs`thread_select(func=<unavailable>, max_fds=<unavailable>, rfds=<unavailable>, wfds=<unavailable>, efds=<unavailable>, timeout=<unavailable>, sigmask=<unavailable>) at thread.c:652:3 [opt]
    frame #5: 0x000000010473ef04 emacs`ns_select_1(nfds=<unavailable>, readfds=<unavailable>, writefds=<unavailable>, exceptfds=<unavailable>, timeout=<unavailable>, sigmask=<unavailable>, run_loop_only=<unavailable>) at nsterm.m:4873:12 [opt] [artificial]
    frame #6: 0x000000010473ed14 emacs`ns_select(nfds=<unavailable>, readfds=<unavailable>, writefds=<unavailable>, exceptfds=<unavailable>, timeout=<unavailable>, sigmask=<unavailable>) at nsterm.m:5006:10 [opt] [artificial]
    frame #7: 0x00000001046e72c0 emacs`wait_reading_process_output(time_limit=<unavailable>, nsecs=<unavailable>, read_kbd=<unavailable>, do_display=true, wait_for_cell=<unavailable>, wait_proc=<unavailable>, just_wait_proc=<unavailable>) at process.c:5766:18 [opt]
    frame #8: 0x000000010460d4b4 emacs`read_char [inlined] kbd_buffer_get_event(kbp=<unavailable>, used_mouse_menu=0x000000016b8d4f67, end_time=0x0000000000000000) at keyboard.c:0 [opt]
!gud 0::/Users/gerd/emacs/github/cl-packages/src/keyboard.c
    frame #9: 0x000000010460d294 emacs`read_char [inlined] read_event_from_main_queue(end_time=0x0000000000000000, local_getcjmp=0x000000016b8d4c00, used_mouse_menu=0x000000016b8d4f67) at keyboard.c:2336:7 [opt]
    frame #10: 0x000000010460d134 emacs`read_char [inlined] read_decoded_event_from_main_queue(end_time=0x0000000000000000, local_getcjmp=0x000000016b8d4c00, prev_event=(struct Lisp_Symbol *) $4 = 0x0000000104e060e0, used_mouse_menu=0x000000016b8d4f67) at keyboard.c:2400:11 [opt]
    frame #11: 0x000000010460d114 emacs`read_char(commandflag=1, map=(struct Lisp_Cons *) $8 = 0x000000010abc8280, prev_event=(struct Lisp_Symbol *) $4 = 0x0000000104e060e0, used_mouse_menu=0x000000016b8d4f67, end_time=0x0000000000000000) at keyboard.c:3031:11 [opt]
    frame #12: 0x000000010460992c emacs`read_key_sequence(keybuf=<unavailable>, prompt=(struct Lisp_Symbol *) $4 = 0x0000000104e060e0, dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=<unavailable>, disable_text_conversion_p=<unavailable>) at keyboard.c:10762:12 [opt]
    frame #13: 0x0000000104607d9c emacs`command_loop_1 at keyboard.c:1435:15 [opt]
    frame #14: 0x000000010468eeb0 emacs`internal_condition_case(bfun=(emacs`command_loop_1 at keyboard.c:1330), handlers=(struct Lisp_Symbol *) $10 = 0x0000000104e06188, hfun=(emacs`cmd_error at keyboard.c:976)) at eval.c:1669:25 [opt]
    frame #15: 0x0000000104607a50 emacs`command_loop_2(handlers=(struct Lisp_Symbol *) $10 = 0x0000000104e06188) at keyboard.c:1174:11 [opt]
!gud 1174:11:/Users/gerd/emacs/github/cl-packages/src/keyboard.c
    frame #16: 0x000000010468e504 emacs`internal_catch(tag=(struct Lisp_Symbol *) $13 = 0x0000000104e0f108, func=(emacs`command_loop_2 at keyboard.c:1170), arg=(struct Lisp_Symbol *) $10 = 0x0000000104e06188) at eval.c:1348:25 [opt]
    frame #17: 0x000000010460714c emacs`command_loop at keyboard.c:1144:13 [opt]
    frame #18: 0x0000000104607008 emacs`recursive_edit_1 at keyboard.c:760:9 [opt]
    frame #19: 0x000000010463e660 emacs`Fread_from_minibuffer [inlined] read_minibuf(map=<unavailable>, initial=<unavailable>, prompt=(struct Lisp_String *) $15 = 0x000000010aba19a8, expflag=<unavailable>, histvar=<unavailable>, histpos=(EMACS_INT) $17 = 0, defalt=<unavailable>, allow_props=<unavailable>, inherit_input_method=<unavailable>) at minibuf.c:905:3 [opt]
!gud 905:3:/Users/gerd/emacs/github/cl-packages/src/minibuf.c
    frame #20: 0x000000010463de28 emacs`Fread_from_minibuffer(prompt=(struct Lisp_String *) $15 = 0x000000010aba19a8, initial_contents=<unavailable>, keymap=(struct Lisp_Cons *) $18 = 0x0000000108f15eb0, read=(struct Lisp_Symbol *) $4 = 0x0000000104e060e0, hist=<unavailable>, default_value=(struct Lisp_String *) $19 = 0x000000010893a840, inherit_input_method=(struct Lisp_Symbol *) $4 = 0x0000000104e060e0) at minibuf.c:1398:9 [opt]
    frame #21: 0x0000000104691b70 emacs`funcall_subr(subr=0x0000000104da0e70, numargs=7, args=<unavailable>) at eval.c:3237:15 [opt]
    frame #22: 0x00000001046de5f0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:828:14 [opt]
    frame #23: 0x0000000104691d0c emacs`funcall_lambda(fun=<unavailable>, nargs=<unavailable>, arg_vector=<unavailable>) at eval.c:3316:9 [opt] [artificial]
    frame #24: 0x0000000104691a40 emacs`funcall_general(fun=<unavailable>, numargs=<unavailable>, args=<unavailable>) at eval.c:3108:12 [opt] [artificial]
    frame #25: 0x000000010468c3f8 emacs`Ffuncall(nargs=9, args=(struct Lisp_Symbol *) $21 = 0x00000002706db770) at eval.c:3157:21 [opt]
    frame #26: 0x0000000104690cac emacs`Fapply(nargs=1, args=(struct Lisp_Symbol *) $25 = 0x0000000244e0e360) at eval.c:2822:24 [opt]
    frame #27: 0x0000000104691ac8 emacs`funcall_subr(subr=0x0000000104da72b0, numargs=1, args=<unavailable>) at eval.c:0 [opt]
    frame #28: 0x00000001046de5f0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:828:14 [opt]
    frame #29: 0x0000000104691d0c emacs`funcall_lambda(fun=<unavailable>, nargs=<unavailable>, arg_vector=<unavailable>) at eval.c:3316:9 [opt] [artificial]
    frame #30: 0x0000000104691a40 emacs`funcall_general(fun=<unavailable>, numargs=<unavailable>, args=<unavailable>) at eval.c:3108:12 [opt] [artificial]
    frame #31: 0x000000010468c3f8 emacs`Ffuncall(nargs=10, args=(struct Lisp_Symbol *) $29 = 0x00000002706db9d0) at eval.c:3157:21 [opt]
    frame #32: 0x0000000104690cac emacs`Fapply(nargs=2, args=(struct Lisp_Symbol *) $32 = 0x0000000244e0e2d0) at eval.c:2822:24 [opt]
    frame #33: 0x0000000104691ac8 emacs`funcall_subr(subr=0x0000000104da72b0, numargs=2, args=<unavailable>) at eval.c:0 [opt]
    frame #34: 0x00000001046de5f0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:828:14 [opt]
    frame #35: 0x0000000104691d0c emacs`funcall_lambda(fun=<unavailable>, nargs=<unavailable>, arg_vector=<unavailable>) at eval.c:3316:9 [opt] [artificial]
    frame #36: 0x0000000104691a40 emacs`funcall_general(fun=<unavailable>, numargs=<unavailable>, args=<unavailable>) at eval.c:3108:12 [opt] [artificial]
    frame #37: 0x000000010468c3f8 emacs`Ffuncall(nargs=10, args=(struct Lisp_Symbol *) $35 = 0x00000002706dbc30) at eval.c:3157:21 [opt]
    frame #38: 0x0000000104690cac emacs`Fapply(nargs=3, args=(struct Lisp_Symbol *) $39 = 0x0000000244e0e280) at eval.c:2822:24 [opt]
    frame #39: 0x0000000104691ac8 emacs`funcall_subr(subr=0x0000000104da72b0, numargs=3, args=<unavailable>) at eval.c:0 [opt]
    frame #40: 0x00000001046de5f0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:828:14 [opt]
    frame #41: 0x0000000104691d0c emacs`funcall_lambda(fun=<unavailable>, nargs=<unavailable>, arg_vector=<unavailable>) at eval.c:3316:9 [opt] [artificial]
    frame #42: 0x0000000104691a40 emacs`funcall_general(fun=<unavailable>, numargs=<unavailable>, args=<unavailable>) at eval.c:3108:12 [opt] [artificial]
!gud 3108:12:/Users/gerd/emacs/github/cl-packages/src/eval.c
    frame #43: 0x000000010468c3f8 emacs`Ffuncall(nargs=<unavailable>, args=(struct Lisp_Symbol *) $42 = 0x00000002706dbef0) at eval.c:3157:21 [opt]
    frame #44: 0x000000010463f3c8 emacs`Fread_buffer(prompt=(struct Lisp_String *) $15 = 0x000000010aba19a8, def=(struct Lisp_String *) $19 = 0x000000010893a840, require_match=(struct Lisp_Symbol *) $45 = 0x00000001084b4d58, predicate=(struct Lisp_Symbol *) $4 = 0x0000000104e060e0) at minibuf.c:0 [opt]
    frame #45: 0x0000000104691bdc emacs`funcall_subr(subr=0x0000000104da0fb0, numargs=3, args=<unavailable>) at eval.c:3231:15 [opt]
    frame #46: 0x00000001046de5f0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:828:14 [opt]
!gud 828:14:/Users/gerd/emacs/github/cl-packages/src/bytecode.c
    frame #47: 0x00000001046dd188 emacs`Fbyte_code(bytestr=<unavailable>, vector=(struct Lisp_Vector *) $48 = 0x00000001084b4808, maxdepth=(EMACS_INT) $50 = 4) at bytecode.c:325:10 [opt]
    frame #48: 0x000000010468b8e8 emacs`eval_sub(form=(struct Lisp_Cons *) $51 = 0x00000001084b47a8) at eval.c:2661:15 [opt]
    frame #49: 0x0000000104690798 emacs`Feval(form=<unavailable>, lexical=<unavailable>) at eval.c:2514:28 [opt]
    frame #50: 0x0000000104688d84 emacs`Fcall_interactively(function=<unavailable>, record_flag=(struct Lisp_Symbol *) $4 = 0x0000000104e060e0, keys=(struct Lisp_Vector *) $52 = 0x000000010ab9ee88) at callint.c:325:15 [opt]
    frame #51: 0x0000000104691c1c emacs`funcall_subr(subr=0x0000000104da68f0, numargs=3, args=<unavailable>) at eval.c:3229:15 [opt]
    frame #52: 0x00000001046de5f0 emacs`exec_byte_code(fun=<unavailable>, args_template=<unavailable>, nargs=<unavailable>, args=<unavailable>) at bytecode.c:828:14 [opt]
    frame #53: 0x0000000104691d0c emacs`funcall_lambda(fun=<unavailable>, nargs=<unavailable>, arg_vector=<unavailable>) at eval.c:3316:9 [opt] [artificial]
    frame #54: 0x0000000104691a40 emacs`funcall_general(fun=<unavailable>, numargs=<unavailable>, args=<unavailable>) at eval.c:3108:12 [opt] [artificial]
    frame #55: 0x000000010468c3f8 emacs`Ffuncall(nargs=2, args=(struct Lisp_Symbol *) $54 = 0x00000002706dc610) at eval.c:3157:21 [opt]
    frame #56: 0x0000000104607fb0 emacs`command_loop_1 at keyboard.c:1556:13 [opt]
    frame #57: 0x000000010468eeb0 emacs`internal_condition_case(bfun=(emacs`command_loop_1 at keyboard.c:1330), handlers=(struct Lisp_Symbol *) $10 = 0x0000000104e06188, hfun=(emacs`cmd_error at keyboard.c:976)) at eval.c:1669:25 [opt]
    frame #58: 0x0000000104607a50 emacs`command_loop_2(handlers=(struct Lisp_Symbol *) $10 = 0x0000000104e06188) at keyboard.c:1174:11 [opt]
    frame #59: 0x000000010468e504 emacs`internal_catch(tag=(struct Lisp_Symbol *) $58 = 0x0000000104e1aba0, func=(emacs`command_loop_2 at keyboard.c:1170), arg=(struct Lisp_Symbol *) $10 = 0x0000000104e06188) at eval.c:1348:25 [opt]
    frame #60: 0x00000001046071c8 emacs`command_loop at keyboard.c:1152:2 [opt]
!gud 1152:2:/Users/gerd/emacs/github/cl-packages/src/keyboard.c
    frame #61: 0x0000000104607008 emacs`recursive_edit_1 at keyboard.c:760:9 [opt]
    frame #62: 0x000000010460740c emacs`Frecursive_edit at keyboard.c:843:3 [opt]
    frame #63: 0x0000000104606134 emacs`main(argc=<unavailable>, argv=0x000000016b8d6c30) at emacs.c:2655:3 [opt]
  frame #64: 0x00000001908a0274 dyld`start + 2840
(lldb)