Subject: 29.0.50; macOS: gdb over ssh into docker stalls

From: Aleksandar Popadić <[email-masked]>
Date: Sat, 12 Mar 2022 12:42:05 +0100

I am not sure if this is an emacs bug or not, but I would be grateful for at least some pointers on how to debug this.  

The issue is that emacs will stall upon hitting a breakpoint until I press C-g. (tramp backtrace is pasted below)

Here is the setup and steps to reproduce:
- macOS v12.2.1 (stuck with it for work) running emacs built from master
- SSH server running in a docker container (minimal Dockerfile to reproduce is attached below)
- run emacs with: ./emacs -Q --eval '(setq tramp-verbose 10)'
- C-x C-f: /ssh:test@localhost#2222:test.c (password is test)
- M-x gdb: gdb -i=mi /ssh:test@localhost#2222:test
- set breakpoints on 3 lines within test.c with C-x C-a C-b
- in *gud-gdb*: run --> breakpoint is hit, all is fine
- continue --> emacs stalls
- after pressing C-g, it unstalls

It works if I connect to an ssh server that is not in a docker container. It also works if I use my personal Debian GNU/Linux machine instead of a mac.

In tramp debug buffer, I see the following:
11:58:17.969961 tramp-accept-process-output (10) # 
  backtrace()
  tramp-error((tramp-file-name "ssh" "test" nil "localhost" "2222" "/home/test/test.c" nil) quit "")
  tramp-signal-hook-function(quit nil)
  accept-process-output(#<process *tramp/ssh test@localhost#2222*> nil nil t)
  tramp-accept-process-output(#<process *tramp/ssh test@localhost#2222*>)
  tramp-wait-for-regexp(#<process *tramp/ssh test@localhost#2222*> nil "\\(^\\|\0\\)[^#$\n]*///f743817e0468bdcc00a56151a4c9b874...")
  tramp-wait-for-output(#<process *tramp/ssh test@localhost#2222*>)
  tramp-send-command((tramp-file-name "ssh" "test" nil "localhost" "2222" "/home/test/test.c" nil) "test -e /home/test/test.c 2>/dev/null; echo tramp_...")
  tramp-send-command-and-check((tramp-file-name "ssh" "test" nil "localhost" "2222" "/home/test/test.c" nil) "test -e /home/test/test.c")
  tramp-sh-handle-file-exists-p("/ssh:test@localhost#2222:/home/test/test.c")
  apply(tramp-sh-handle-file-exists-p "/ssh:test@localhost#2222:/home/test/test.c")
  tramp-sh-file-name-handler(file-exists-p "/ssh:test@localhost#2222:/home/test/test.c")
  apply(tramp-sh-file-name-handler file-exists-p "/ssh:test@localhost#2222:/home/test/test.c")
  tramp-file-name-handler(file-exists-p "/ssh:test@localhost#2222:/home/test/test.c")
  file-exists-p("/ssh:test@localhost#2222:/home/test/test.c")
  gud-file-name("/home/test/test.c")
  gud-find-file("/home/test/test.c")
  gud-display-line("/home/test/test.c" 2)
  gud-display-frame()
  gdb-frame-handler()
  gdb-handle-reply(29)
  gdb-done-or-error("29" done "frame={level=\"0\",addr=\"0x000055e839174131\",func=\"m..." t)
  gdb-done("29" "frame={level=\"0\",addr=\"0x000055e839174131\",func=\"m..." t)
  gdbmi-bnf-incomplete-record-result("29" (gdb-done . progressive))
  #f(compiled-function () #<bytecode 0x1fdfe192a9cab>)()
  gdbmi-bnf-result-and-async-record-impl()
  gdbmi-bnf-async-record()
  gdbmi-bnf-out-of-band-record()
  gdbmi-bnf-output()
  gud-gdbmi-marker-filter("cx\",\"edx\",\"esi\",\"edi\",\"ebp\",\"esp\",\"r8d\",\"r9d\",\"r10...")
  apply(gud-gdbmi-marker-filter "cx\",\"edx\",\"esi\",\"edi\",\"ebp\",\"esp\",\"r8d\",\"r9d\",\"r10...")
  gud-marker-filter("cx\",\"edx\",\"esi\",\"edi\",\"ebp\",\"esp\",\"r8d\",\"r9d\",\"r10...")
  gud-filter(#<process gud-test> "cx\",\"edx\",\"esi\",\"edi\",\"ebp\",\"esp\",\"r8d\",\"r9d\",\"r10...")
11:58:17.970127 tramp-accept-process-output (1) # Quit: "Quit", ""

In *Messages* I would see:
Quit: "Quit", ""
error in process filter: Quit [2 times]
WARNING! Discarding GDB handler with token #29

I don't know if the following is related as I observe it also in cases when it works. In *input/output of test* buffer, i see:
&"warning: GDB: Failed to set controlling terminal: Operation not permitted\n"

In GNU Emacs 29.0.50 (build 1, x86_64-apple-darwin21.3.0, NS appkit-2113.30 Version 12.2.1 (Build 21D62))
 of 2022-03-09 built on apopadic.local
Repository revision: fab840e381db8b5fd226f59d976abd3e4f16bec4
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2113
System Description:  macOS 12.2.1

Configured using:
 'configure --with-ns --with-mailutils --with-imagemagick --with-cairo
 --with-modules --with-xml2 --with-gnutls --with-json --with-rsvg
 --disable-silent-rules --disable-ns-self-contained --without-dbus'

Configured features:
ACL GIF GLIB GMP GNUTLS IMAGEMAGICK JPEG JSON LCMS2 LIBXML2 MODULES
NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP XIM ZLIB

Important settings:
  value of $LC_CTYPE: UTF-8
  locale-coding-system: utf-8-unix

Major mode: Debugger

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media rmc puny
dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068
epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils gdb-mi gud vc-hg vc-git
diff-mode vc-bzr help-fns radix-tree cl-print backtrace help-mode
find-func vc-dispatcher cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs noutline outline easy-mmode
tramp-cache tramp-sh tramp tramp-loaddefs trampver tramp-integration
files-x tramp-compat shell pcomplete comint ansi-color ring parse-time
iso8601 time-date ls-lisp format-spec auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs cl-loaddefs cl-lib password-cache json
map seq gv subr-x byte-opt bytecomp byte-compile cconv iso-transl
tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 183353 15572)
 (symbols 48 11873 1)
 (strings 32 38355 2131)
 (string-bytes 1 1370631)
 (vectors 16 23415)
 (vector-slots 8 311949 29985)
 (floats 8 212 243)
 (intervals 56 30433 0)
 (buffers 992 20))

Best regards
Aleksandar Popadić