Subject: Re: bug#40323: 28.0.50; error in process filter: Invalid search bound (wrong side of point)

From: Noam Postavsky <[email-masked]>
Date: Mon, 30 Mar 2020 10:50:55 -0400

Jacob Lagares Pozo <[email-masked]> writes:

> Debugger entered--Lisp error: (error "Invalid search bound (wrong side of point)")
>   re-search-forward("\33\\[[0-?]*[ -/]*[@-~]" #<marker at 1 in *Async Shell Command*> t)
>   ansi-color-apply-on-region(#<marker at 152 in *Async Shell Command*> #<marker at 1 in *Async Shell Command*>)
>   ansi-color-process-output("[03/29/20, 16:21:53:387] info: [FOCUS-EVENT] Clien...")
>   run-hook-with-args(ansi-color-process-output "[03/29/20, 16:21:53:387] info: [FOCUS-EVENT] Clien...")
>   comint-output-filter(#<process Shell> "[03/29/20, 16:21:53:387] info: [FOCUS-EVENT] Clien...")

It looks like the start and end markers are the wrong way around.  Does
the patch below help?  If yes, the next question would be how they got
that way.  Perhaps that indicates a problem in comint.el?

--- i/lisp/ansi-color.el
+++ w/lisp/ansi-color.el
@@ -222,6 +222,10 @@ ansi-color-process-output
 			  comint-last-output-start
 			(point-min-marker)))
 	(end-marker (process-mark (get-buffer-process (current-buffer)))))
+    (when (> start-marker end-marker)
+      (let ((s start-marker))
+        (setq start-marker end-marker
+              end-marker s)))
     (cond ((eq ansi-color-for-comint-mode nil))
 	  ((eq ansi-color-for-comint-mode 'filter)
 	   (ansi-color-filter-region start-marker end-marker))