Subject: Re: bug#16003: 24.3.50; "Stack overflow in equal" in advice--member-p

From: Stefan Monnier <[email-masked]>
Date: Fri, 29 Nov 2013 14:09:02 -0500

> I've been getting this kind of errors lately.  Unfortunately, I've been
> unable to reproduce it from `emacs -Q' so far, but here are two
> backtraces, one from `vc-dir-mode', and another from
> `diff-hl-dired-mode'.

The patch below should avoid the problem.
But we really should try and improve `equal' not to fail this way.

        Stefan

=== modified file 'lisp/vc/vc-dispatcher.el'
--- lisp/vc/vc-dispatcher.el	2013-11-28 01:49:25 +0000
+++ lisp/vc/vc-dispatcher.el	2013-11-29 19:03:35 +0000
@@ -239,10 +239,12 @@
      ;; If a process is running, add CODE to the sentinel
      ((eq (process-status proc) 'run)
       (vc-set-mode-line-busy-indicator)
-      (letrec ((fun (lambda (p _msg)
-                      (remove-function (process-sentinel p) fun)
+      (let* ((funsym (make-symbol "fun"))
+             (fun (lambda (p _msg)
+                    (remove-function (process-sentinel p) funsym)
                       (vc--process-sentinel p code))))
-        (add-function :after (process-sentinel proc) fun)))
+        (fset funsym fun)
+        (add-function :after (process-sentinel proc) funsym)))
      (t (error "Unexpected process state"))))
   nil)