Subject: Re: bug#69327: 29.2.50; Emacs crashes when running gdb with comint-prompt-read-only

From: Eli Zaretskii <[email-masked]>
Date: Fri, 23 Feb 2024 17:41:16 +0200

> From: Knut Anders Hatlen <[email-masked]>
> Date: Fri, 23 Feb 2024 10:12:25 +0000
> 
> Then run emacs -Q and evaluate:
> 
> (progn
>   (setopt gdb-debuginfod-enable-setting nil
>           comint-prompt-read-only t)
>   (gdb "gdb -i=mi a.out")
>   (insert "r")
>   (comint-send-input)
>   (sit-for 2)
>   (gdb "gdb -i=mi b.out"))

Does gdb-mi.el really support several debugging sessions in parallel?

> According to git bisect, it has crashed since the
> gdb-debuginfod-enable-setting option was introduced in:
> 
> commit ab417c8a6eeb7df7ccce3e5f8416f48544a5174e
> Author: Eli Zaretskii <[email-masked]>
> Date:   Tue Mar 7 14:39:27 2023 +0200
> 
>     Fix problem with debuginfod queries in "M-x gdb"
>     
>     * lisp/progmodes/gdb-mi.el (gdb-debuginfod-enable-setting): New
>     defcustom.
>     (gdb-debuginfod-message): New function.
>     (gdb-init-1): Initialize gdb-debuginfod-enable.  Ask the user
>     about debuginfod queries and display any error messages.
>     (Bug#61973)
>     
>     * etc/NEWS: Announce the change.

Does replacing defvar with defvar-local for
gdb-debuginfod-enable-setting helps to resolve the problem?

If not, please tell what are the errors that Emacs wants to report,
here:

  #10685 0x00005555557a971b in read_process_output_error_handler (error_val=<optimized out>) at ../../src/process.c:6140
  #10686 0x000055555575462c in internal_condition_case_1 (bfun=bfun@entry=0x5555557a97a0 <read_process_output_call>, arg=XIL(0x7fffef130093), handlers=handlers@entry=XIL(0x90), hfun=hfun@entry=0x5555557a96e0 <read_process_output_error_handler>) at ../../src/eval.c:1557
	  val = <optimized out>
	  c = 0x555555ebab70
  #10687 0x00005555557ac215 in read_and_dispose_of_process_output (coding=<optimized out>, nbytes=157, chars=0x7fffffffc420 "=cmd-param-changed,param=\"debuginfod enabled\",value=\"off\"\n~\"Reading symbols from b.out...\\n\"\n~\"(No debugging symbols found in b.out)\\n\"\n(gdb) \n1^done\n(gdb) \nater <http://gnu.org/licenses/gpl.html>\\nTh"..., p=0x5555561b66f8) at ../../src/process.c:6354

and here:

  #10679 0x00005555557a971b in read_process_output_error_handler (error_val=<optimized out>) at ../../src/process.c:6140
  #10680 0x000055555575462c in internal_condition_case_1 (bfun=bfun@entry=0x5555557a97a0 <read_process_output_call>, arg=XIL(0x7fffef12d703), handlers=handlers@entry=XIL(0x90), hfun=hfun@entry=0x5555557a96e0 <read_process_output_error_handler>) at ../../src/eval.c:1557
	  val = <optimized out>
	  c = 0x555555ebab70
  #10681 0x00005555557ac215 in read_and_dispose_of_process_output (coding=<optimized out>, nbytes=14, chars=0x7fffffffae40 "1^done\n(gdb) \n", p=0x5555561b66f8) at ../../src/process.c:6354

I'm asking about the value of error_val with which
read_process_output_error_handler is called in these two frames.  It
is possible that you will need to rebuild Emacs without optimizations,
to be able to show these values.  The error_val argument is a Lisp
object, so please use the "pp" command to show it (if GDB says it
doesn't know about "pp", you need to "source .gdbinit" where .gdbinit
is the file that comes with the Emacs source tarball, in the 'src'
directory).

> When setting comint-prompt-read-only to nil, it seems to behave fine
> regardless of which value gdb-debuginfod-enable-setting has.

Why are you setting comint-prompt-read-only non-nil?

Thanks.