Subject: Re: 28.0.50; process-send-string mysteriously exiting non-locally when called from timer

From: João Távora <[email-masked]>
Date: Thu, 10 Dec 2020 16:29:09 +0000

João Távora <[email-masked]> writes:

> Eli Zaretskii <[email-masked]> writes:
>
>>> From: João Távora <[email-masked]>
>>> Cc: [email-masked]
>>> Date: Thu, 10 Dec 2020 15:00:58 +0000
>>> 
>>>     6       breakpoint     keep y   0x0000555555966de5 in unwind_to_catch at eval.c:1178
>>>             stop only if bidi_inhibit_bpa != 0
>>
>> You have put the breakpoint at the point where sys_longjmp is about to
>> be called, right?  But all the unwind forms are already done at that
>> point, so I guess bidi_inhibit_bpa is again zero, and the breakpoint
>> doesn't break.  So I suggest to move the breakpoint before the
>> do-while loop in unwind_to_catch:
>>
>
> Yes! good idea! though I don't udnerstand why that breakpoint _did_ break
> when I did
>
>    (let ((bidi-inhibit-bpa t)) (error "test-error"))
>
> Anyway, it seems process_quit_flag is being called and throwing (though
> I don't see "Quit" in the *Messages*). And didn't you tell me that idle
> timers run with inhibit-quit = t?  But inhibit-quit seems to be nil,
> (which I also confirmed from Elisp.)  I looked in the sly source and am
> quite sure I'm not binding it to nil in that circunstance.

Aha! I found the culprit.  It is eldoc.el.  It seems to be a
longstanding policy to call Eldoc backends with `with-no-input`.  This
is obviously badly problematic for aynchronous backends.

Stefan, I think this change has to go.  Now that we have proper (or more
proper) async support in eldoc.el, we shouldn't need these tricks: just
use a timer or a process or sth.

Else we must super clearly document that the
eldoc-documentation-function can stop at any moment for whatever reason
and that it's probably a good idea to bullet-proof your async code with
inhibit-quit=t.

In the meantime I'll do that, forcing inhibit-quit back to t in
sly-autodoc.el.

That should fix it.  Thanks a lot, Eli!  Really amazing.

João

commit 12e922156c86a26fa4bb2cb9e7d2b3fd639e4707
Author: Stefan Monnier <[email-masked]>
Date:   Tue Dec 4 18:15:44 2018 -0500

    * lisp/emacs-lisp/eldoc.el: Let the user interrupt the search
    
    (eldoc-print-current-symbol-info): Use while-no-input and non-essential.

diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -360,6 +365,4 @@
-    (and (or (eldoc-display-message-p)
-             ;; Erase the last message if we won't display a new one.
-             (when eldoc-last-message
-               (eldoc-message nil)
-               nil))
-	 (eldoc-message (funcall eldoc-documentation-function)))))
+        ;; Only keep looking for the info as long as the user hasn't
+        ;; requested our attention.  This also locally disables inhibit-quit.
+        (while-no-input
+          (eldoc-message (funcall eldoc-documentation-function)))))))