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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 24 Feb 2024 10:40:35 +0200

> From: Knut Anders Hatlen <[email-masked]>
> Cc: [email-masked]
> Date: Fri, 23 Feb 2024 21:16:50 +0100
> 
> It apparently tries to report "error in process filter: Text is
> read-only" in all of the read_process_output_error_handler() frames that
> I looked at. error_val contains the same in all of them:
> 
> (gdb) pp error_val
> (text-read-only)

OK, so please try this change, it seems to fix the problem for me:

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index d119eeb..312b71b 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1849,7 +1849,8 @@ gdb-io-eof
 
 (defun gdb-clear-inferior-io ()
   (with-current-buffer (gdb-get-buffer-create 'gdb-inferior-io)
-    (erase-buffer)))
+    (let ((inhibit-read-only t))
+      (erase-buffer))))
 
 
 (defconst breakpoint-xpm-data
@@ -2819,7 +2820,8 @@ gdb-append-to-partial-output
 
 (defun gdb-clear-partial-output ()
   (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer)
-    (erase-buffer)))
+    (let ((inhibit-read-only t))
+      (erase-buffer))))
 
 ;; Parse GDB/MI result records: this process converts
 ;;  list      [...]      ->  list