Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected reply #385

Closed
mfiano opened this issue Dec 7, 2020 · 51 comments
Closed

Unexpected reply #385

mfiano opened this issue Dec 7, 2020 · 51 comments

Comments

@mfiano
Copy link

mfiano commented Dec 7, 2020

This started happening a few months ago, and I'm just getting around to reporting it because it is quite annoying. Every few minutes, this error is invoked, which pauses Emacs for a good 5 seconds while I am typing.

error in process filter: sly-dispatch-event: Unexpected reply: 1778 (:ok ("(define-hook ===> hook-type <=== (self component-type &key (optimize t)) &body body)" t))
error in process filter: Unexpected reply: 1778 (:ok ("(define-hook ===> hook-type <=== (self component-type &key (optimize t)) &body body)" t))

Here's another occurence in my Messages buffer:

-event: Unexpected reply: 904 (:ok ("(defun name ===> lambda-list <=== &body body)" t))
error in process filter: Unexpected reply: 904 (:ok ("(defun name ===> lambda-list <=== &body body)" t))

and another:

error in process filter: sly-dispatch-event: Unexpected reply: 606 (:ok (:not-available t))
error in process filter: Unexpected reply: 606 (:ok (:not-available t))

and another:

error in process filter: sly-dispatch-event: Unexpected reply: 165 (:ok (:not-available t))
error in process filter: Unexpected reply: 165 (:ok (:not-available t))

and one more from today:

error in process filter: sly-dispatch-event: Unexpected reply: 2999 (:ok (:not-available t))
error in process filter: Unexpected reply: 2999 (:ok (:not-available t))
@mfiano mfiano changed the title Unexpected reply: 1778 Unexpected reply Dec 7, 2020
@joaotavora
Copy link
Owner

Yuck, this isn't good. I see this once in a while , too, but not nearly "every few minutes". I see it once a week at most. It's very hard to pin down. You can give me some help tho:

  1. Tell me how often you see this. Is it really every few minutes? That's very odd, but in a sense good.
  2. Since it's so easy to reproduce for you, Git bisecting to an offending prior commit would be extremely useful.

João

@mfiano
Copy link
Author

mfiano commented Dec 7, 2020

@joaotavora I would say every 20 minutes to an hour, so not that easy to bisect. Is there anything else I can do to help pin it down?

@joaotavora
Copy link
Owner

In principle, with the Elisp evaluation model I know, this shouldn't matter, but you can try with this patch:

diff --git a/sly.el b/sly.el
index ae88a8ed..ca58bf24 100644
--- a/sly.el
+++ b/sly.el
@@ -2541,8 +2541,8 @@ Debugged requests are ignored."
            (when (and (sly-use-sigint-for-interrupt) (sly-busy-p))
              (sly-display-oneliner "; pipelined request... %S" form))
            (let ((id (cl-incf (sly-continuation-counter))))
-             (sly-send `(:emacs-rex ,form ,package ,thread ,id ,@extra-options))
              (push (cons id continuation) (sly-rex-continuations))
+             (sly-send `(:emacs-rex ,form ,package ,thread ,id ,@extra-options))
              (sly--refresh-mode-line)))
           ((:return value id)
            (let ((rec (assq id (sly-rex-continuations))))

@joaotavora
Copy link
Owner

The code path that I'm thinking about should be equivalent to SLIME's, so I find this very strange. Maybe you upgraded Emacs versions a month ago or something like that?

@mfiano
Copy link
Author

mfiano commented Dec 7, 2020

I am on Arch Linux, so get frequent updates, yes. Currently on Emacs 27.1

@joaotavora
Copy link
Owner

I am on Arch Linux, so get frequent updates, yes. Currently on Emacs 27.1

That's fairly recent, and what I use as well (actually I use master). Maybe you can downgrade momentarily to 26.3 or keep it besides Emacs 27.

Anyway, this seems to be Eldoc/Autodoc exclusive, so shooshing those errors in those circunstances could be an option. But I'd like to get to the bottom of it. Please try my patch for a while.

@mfiano
Copy link
Author

mfiano commented Dec 7, 2020

Actually, come to think of it, this started happening when I upgraded from 27 to 27.1 back when it was released in August, but I also updated all my Emacs packages at the same time, so...

@joaotavora
Copy link
Owner

From 27 to 27.1? That's odd. Were you using a pretest? Or did you mean 26?

@mfiano
Copy link
Author

mfiano commented Dec 7, 2020

Let me consult my Linux package update log...

[2020-02-21T00:39:27+0000] [ALPM] installed emacs (26.3-1)
[2020-05-22T22:03:46-0400] [ALPM] upgraded emacs (26.3-1 -> 26.3-2)
[2020-08-13T17:39:33-0400] [ALPM] upgraded emacs (26.3-2 -> 27.1-2)

Ah, sorry. So it happened with 26.3 -> 27.1.

@joaotavora
Copy link
Owner

Nice linux distro btw. Someday I'll switch myself, what "flavor" of Arch, if any, are you on?

@mfiano
Copy link
Author

mfiano commented Dec 7, 2020

Plain old Arch Linux.

@joaotavora
Copy link
Owner

joaotavora commented Dec 7, 2020

Anyway, so as you can see by my patch, my suspicion/working hypothesis is that 27.1 somehow allowed (contrary to 26.3) sly-send or its calles to receive output from subprocesses "prematurely". Basically Eldoc/Autodoc would have responded so damn quickly that there wouldn't have been enough time to run the next statement so when they reply back the "continuation" isn't there and you get that error. So the solution would be to first register the continuation, and then send sly-send.

EDIT: this working hypothesis is now known invalid. The real reason is that process-send-string is sometimes silently exiting non-locally when called from a timer.

@mfiano
Copy link
Author

mfiano commented Dec 7, 2020

Sure, I am upgrading my packages right now, then I will try your patch, and perhaps Emacs HEAD. Thanks

@joaotavora
Copy link
Owner

Actually, I wouldn't do that. I would try one thing at a time.

@joaotavora
Copy link
Owner

Starting with the patch, maybe.

@mfiano
Copy link
Author

mfiano commented Dec 7, 2020

Yes, I know. I have some other outstanding Emacs issues to take care of too, so first I'm updating packages and inspecting all that. I have a backup on my NAS of the previous state in case things go awful, and to try your patch in isolation.

@mfiano
Copy link
Author

mfiano commented Dec 8, 2020

@joaotavora With your patch, eldoc no longer gives any hints at all.

@mfiano
Copy link
Author

mfiano commented Dec 8, 2020

In looking over my Emacs config though I have (setq eldoc-idle-delay 0.1) which differs from the default of 0.5 because I wanted it more responsive. This leads me to believe there could be some kind of race condition. I will change it to the default in the meantime and see if that helps reduce the chance, even if that is an ugly hack.

joaotavora added a commit that referenced this issue Dec 8, 2020
* sly.el (sly-dispatch-event): Move sly-send a line below.
@joaotavora
Copy link
Owner

@joaotavora With your patch, eldoc no longer gives any hints at all.

Wow, that is something. I've pushed a branch with the patch. Please point your copy of SLY to it, make sure you don't have any stale .elc files, and try to reproduce the problem with a bare Emacs.

@joaotavora
Copy link
Owner

and try to reproduce the problem with a bare Emacs.

By problem I mean any of the two problems, the error or the missing ElDoc. By bare Emacs I mean Emacs -Q.

@mfiano
Copy link
Author

mfiano commented Dec 8, 2020

eldoc seems to be working, even though nothing appears to be different from that patch and what i changed. And I always delete elc files between each run in these types of cases. Will keep an eye out for the error now

@mfiano
Copy link
Author

mfiano commented Dec 8, 2020

I spoke too soon. eldoc stopped printing out signatures in the minibuffer.

@joaotavora
Copy link
Owner

joaotavora commented Dec 8, 2020 via email

joaotavora added a commit that referenced this issue Dec 8, 2020
* sly.el (sly-dispatch-event): handle mysterious sly-send
non-local exits.
@joaotavora
Copy link
Owner

joaotavora commented Dec 8, 2020 via email

@joaotavora
Copy link
Owner

I've pinned this down to a likely Emacs bug. Here is the report I made: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45117

@mfiano The most recent commit will probably be the end of it regardless of whether the problem is fixed in Emacs or not, but I'd still appreciate that you'd test it.

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

Interesting. Nice debugging there! I will be using your latest commit and let you know how it goes.

P.S. South Bank Common Lisp is not a thing :)

@joaotavora
Copy link
Owner

P.S. South Bank Common Lisp is not a thing :)

Nah-ah!!!, it's a thing I got here that noone knows and only I use!

🤦 🤦

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

Unfortunately, your latest changes didn't solve the issue:

error in process filter: sly-dispatch-event: Unexpected reply: 192 (:ok ("(let bindings &body ===> body <===)" t))
error in process filter: Unexpected reply: 192 (:ok ("(let bindings &body ===> body <===)" t))

error in process filter: sly-dispatch-event: Unexpected reply: 274 (:ok ("(defun name lambda-list &body ===> body <===)" t))
error in process filter: Unexpected reply: 274 (:ok ("(defun name lambda-list &body ===> body <===)" t))

@joaotavora
Copy link
Owner

Likely you didn't compile them, or have a stale elc.. I'll look later but you can substitute the latest by the if version that prints something everytime it catches the bug. Try that.

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

I made sure to remove all packages, not just ELC, but everything, and did a checkout of that specific branch for Sly.

@joaotavora
Copy link
Owner

I still think you missed something. I'll push a version with a little bit more debugging info and then we can check Messages to be sure.

@joaotavora
Copy link
Owner

Thinking x2 about it, there is indeed a possibility of unexpected reply, I just never got it (and I got a lot of observations of the bug). but lets run this version so we get more feedback.

@joaotavora
Copy link
Owner

By the way, you don't have to completely purge everything to get this, just go to the sly.el file and re-evaluate that definition

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

Give me a few minutes to finish up and I will try. I will say though, that the previous patch seemed to result in the error far less often, or it could just be the computer gods laughing at me. In any case, I will run with the latest for a while and report what I see.

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

After a few minutes, this is in *Messages*

[sly] Connecting to Slynk on port 41235..
[sly] Connected. Hack and be merry!
[sly] [issue#385] likely `process-send-string' exited non-locally from timer.
[sly] [issue#385] likely `process-send-string' exited non-locally from timer. [2 times]

@joaotavora
Copy link
Owner

And also some "unexpecteds?"

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

Negative

@joaotavora
Copy link
Owner

let's wait though, I think eventually you'll bump into one.

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

I copied some code I already wrote, typing as fast as I could, as that seems to generate them quickly:

[sly] Connecting to Slynk on port 41235..
[sly] Connected. Hack and be merry!
[sly] [issue#385] likely `process-send-string' exited non-locally from timer.
No completion found
[sly] [issue#385] likely `process-send-string' exited non-locally from timer. [10 times]
next-line: End of buffer
[sly] [issue#385] likely `process-send-string' exited non-locally from timer. [5 times]
Beginning of buffer [2 times]

@joaotavora
Copy link
Owner

yeah, with a short eldoc-idle-delay it seems to happen very often. No "unexpecteds" though, right?

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

No unexpecteds with the latest patch.

@joaotavora
Copy link
Owner

(the latest patch is the same as the one before, btw :-) just more debugging info)

@joaotavora
Copy link
Owner

Anyway, keep testing, I think you'll reach an unexpected or two, by my calculations, it's certainly possible, and likely that was happening before. It would also explain the perceived decrease in frequency you mentioned.

@joaotavora
Copy link
Owner

When you confirm this, I'll have a patch to fix those

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

Sure I will keep testing. Just to be clear:

  • When the "unexpected"s were frequent, every time they popped up, Emacs would freeze for about 5 seconds.

  • When they pop up rarely, they still freeze Emacs for about 5 seconds, but the frequent debug message that is emitted now does not freeze Emacs.

@joaotavora
Copy link
Owner

By the way. It's great that you use SLY so intensively and take the time to report these bugs and help me debug them. Very appreciated 👌

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

So, it's much more bearable now at least. Oh no problem at all. Thank you for being such a great maintainer, because I know you're a very busy person.

@joaotavora
Copy link
Owner

When they pop up rarely, they still freeze Emacs for about 5 seconds, but the frequent debug message that is emitted now does not freeze Emacs.

Right, the debug message is just a tracer. You can comment it out.

@mfiano
Copy link
Author

mfiano commented Dec 9, 2020

Yep:

error in process filter: sly-dispatch-event: Unexpected reply: 1986 (:ok ("(define-compiler-macro make-component (type &rest ===> args <===) &body body)" t))
error in process filter: Unexpected reply: 1986 (:ok ("(define-compiler-macro make-component (type &rest ===> args <===) &body body)" t))

@joaotavora
Copy link
Owner

After some very intensive investigation, I came to the correct fix. I shall be ⚡ if this doesn't fix it. Problem was in Emacs, but in Elisp and not in C, thankfully.

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45117

@mfiano
Copy link
Author

mfiano commented Dec 11, 2020

Excellent. Thank you for all your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants