-
Notifications
You must be signed in to change notification settings - Fork 162
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
Malformed background commands hang Emacs #1110
Comments
There is no background processes in ESS, only background tasks that are hidden from the user. Can you please provide debugging info? I've added Also if you suspect this is because of your
I don't know but can you please at least try it without tracebug to confirm this? |
Even emacs key-strokes have no effect.... apart from C-g C-g C-g which still leaves that strange mode. Note that also the "blinking rectangle" which shows the "cursor" in the active buffer disappears. |
and then saving the
A longer version I try to attach |
sure; the above was already with default |
Well, yes, I don't know the emacs terminology. So it is such a background task which eats away all emacs resources, even keystroke actions are delayed for many minutes in my case, just 3 x
in the trace-output buffer, it's "frozen" again (to be thawed by C-g C-g C-g) ... |
This is strange. You can normally safely ignore the ESS timer, it runs every second and so this is normal output. You can also ignore lines like Just to confirm, what do you have in
3x C-g is indicative of an
Oh then without tracebug. It would be helpful to determine if this config change causes the problem or if it's the recently merged PR. |
Thank you for the trace. This might be relevant:
Especially this part which suggests a parse error:
It's trying to evaluate a long background command which starts like this: local({
list_templates <-
function(user_dirs) {
user_dirs <- c(user_dirs, unlist(lapply(user_dirs, list.dirs, recursive = FALSE)))
... I'm not familiar with this command, do you know what it is about? I see this which might be relevant to your heavy libpath: packages <- sort(unlist(lapply(.libPaths(), dir))) That said, we're now supposed to handle hanging ESS-commands gracefully, I'm disappointed we're not there yet :( |
Oh of course anything in a process filter is behind an inhibit quit so that might be from the filter. |
Analysing your trace, it looks like:
So it looks like everything is working as expected here, except that you would see a long freeze (that should be interruptible with a single C-g) since the command does not parse. The cause may be elsewhere. |
misunderstanding: You asked me on #973 to see if that issue (ess-use-tracebug nil ==> extra [Enter] generated) is solved now, so I switched back to my previous setting 'nil'. Then I got this issue (but also after updating all packages, notably poly-R ..), git pulling ess, make, etc... so now I have tried both with 'nil' and with 't' and the background task killing interactivity phenomenon is there in both cases.. |
Thank you for confirming the tracebug filter is not the cause. Can you please checkout this commit and try again? a9ee60c To determine whether today's PR is at fault. |
or it is my update of |
I did |
Oh that makes sense, I think we're making good progress :) That bit might be registering a regularly executing command: https://github.com/polymode/poly-R/blob/51ffeb6ec45dd44eafa4d22ad2d6150cc4b248fc/poly-R.el#L217-L224 Since it doesn't parse and since we've bumped the timeout to 30s this explains the hangs as soon as you stop interacting with Emacs. So I'm going to find a solution for these malformed commands because they are too dangerous. I think I'll send the string to Still one unexplained observation: having to C-g 3 times. This means there is an |
just on one of your notes: single C-g does not have any effect; it's really the triple one that's needed currently. |
Ok, only read that now. I will grep around a bit in my emacs setup. |
oh it's more likely in the background invokation code, maybe easy-menu? I'm not familiar with this package. |
So, in my |
This particular |
I have thought so
I did not suggest so, but that the hang would happen in code called from that part of As a user the difference is not really that large between one |
@lionel- you are moving way to fast with the modifications of ess-command. I don't have the breadth to fully follow and understand your experimentation but very quick changes like that is nothing else than playing with fire IMO. That's critical code and I think changing how it works should be carefully considered. |
I never saw such hangs, I automatically browse some of the menus quite regularly ... so for some reasons the old version of poly-R I had .. could well be even older or was not triggered as easily. |
@mmaechler that would mean you had 2years old poly-R, which is pretty unlikely no? To make sure that it's indeed poly-R, would you mind pulling an older ESS (before ess-command changes), say |
Vitalie, this is rather uncalled for. The switch to output delimiters and to There has been some fallout from these changes as would be expected. When I see problems with remotes (cf last week issues) or with malformed commands (this issue) I take the time to fix them ASAP to unblock users of the dev version. I also add unit tests, which takes a lot of my time. That's moving too fast and playing with fire? Please be considerate of my work and my time. The problem with Martin's issue is rather complicated, here is how I understand it:
I've started work on a fix for malformed commands in lionel-@3cabdc51. I think this will solve the issue generically. However it will not solve Martin's problem with the malformed command which I believe is external to ESS. It's also quite possible I'm missing something so I keep an open mind to alternative explanations of Martin's trace. It's also possible there are multiple problems causing his observations. |
I just stated that you are making changes to critical code way too fast and I don't have time to catch up. Not more, not less. Nothing personal or disrespectful implied or intended. Of course I respect your time and know how crazily hard you work and how many days and weeks of time is invested here. In fact seeing insult where it is not probably means you are badly overworked, so maybe a slower tempo would be indeed beneficial here. If we take more time and discuss things slowly I am sure we can come up with globally optimal solutions faster. Otherwise one person can pile a lot of new infra and we might end up replacing it anyhow in the future. As an example a lot of issues that you are dealing right now (delimiters, partial accumulation of output, async execution, passing R errors to emacs level et) do overlap and have been considered with the already implemented simple MPI framework that we have. And I don't think you had a look at it so far. |
Regarding MPI, I chose to keep things simple because we were dealing with hard to fix bugs. ESS has been quite unstable for a while before this and I did not have a complete picture of how this all worked. MPI seemed to add a layer of complexity that was not desirable to start with. We can switch to MPI for sending messages (sentinels and errors) in the close or far future. I don't think it's incompatible and the overlap is small really. Also we've always accumulated output in ESS commands, that's not new. |
@mmaechler Have you updated your branch? |
Here is a reprex: (ess-command "1\n2\n") This evaluates |
I was overthinking probably. My concern was that the command run as part of ess-command would invokeRestarts, but I guess that's too much to allow for anyhow.
What about |
I don't know the internals of recover but it is not relevant here because the process is not "ready" when recovering. The prompt is looking for a frame number rather than an R expression so there is no Edit: oh I guess you meant a browser prompt after choosing a frame number in |
I introduced this silly bug a while ago :( Still need to fix the hang when commands are actually malformed, so I'm keeping this open. @mmaechler You should now have a usable ESS if you checkout the latest master. |
(indeed, it's back to well usable, thank you!) |
Well, I'm currently suffering again ... and I think only since I terrible timeouts, and
in the Still much better than having timeouts and nothing in both |
It really is about saving |
This is strange, it seems a bit improbable for Also what do you get when you run |
This is unlikely because ESS doesn't register any save hook. Can you look in your save hooks and confirm, if you think this is the case? FWIW the timeouts seem to be triggered by |
Thank you for mentioning the fact that other timers are likely to be the case.. rather than save-file-hooks.
|
We can't crack the case with so few information. Here are a few things you could do:
|
I got the |
Since today, I'm suffering again from complete lockup when I start emacs (which loads many things, notably
|
Well, of course At the moment, I can just kill emacs from the OS (or the GNOME gui) ... |
If you can't C-g at all it may be a bug in Emacs. After upgrading to Emacs 27 on macOS I faced systematic freezes. I "fixed" it by installing a fork that uses a different implementation for the macOS glue. It turns out that the built-in macOS layer is less stable than the fork. The Linux layer should be more stable than the macOS one though. |
Thank you, @lionel-; this is "stock" emacs 27.1 from Fedora Linux 32 ... and we are soon upgrading to F 34. |
The timeouts are set to 30 seconds, could it really take that long? Just to be sure you could add this to your config to set the timeouts to infinity: (defvar ess--command-default-timeout most-positive-fixnum)
This mode is a single block of code and has no dependencies so you could copy it in your config to make it available earlier. |
Do you also have the freezes when |
The problem "went away" (i.e., has no longer been exposed!) after a reboot and the disk-network server being back to speed. |
The problem likely occurs in one of these steps:
If that's the case, setting |
It seems I may have opened a partial duplicate of this issue in #1162. The trigger isn't the exact same, but the behaviour enumerated by @mmaechler here is essentially what I encounter and couldn't describe easily.
Since setting |
Should be fixed by polymode/poly-R#38 which adds a timeout of 200ms to the background command launched by the poly-R menu. If you see sluggishness instead of hangs because the timeout is too large, you can add this to your config to disable the background eval altogether: Does this solve it for you @mmaechler? |
Closing since Martin confirmed on polymode/poly-R@8024e85 that this fixed the hang 🎉 |
This is very new; just from today, git pulling and restarting emacs.
emacs -f R
to just start an*R*
inferior buffer, no R script for the moment (yes, atypical for me).This even "kills" the mouse - emacs-menu interaction: If I click on one of the menus, nothing happens .... well about 5 minutes later when I've given up on that emacs, the pull down menu suddenly opens (on top of firefox in this case which has been my 'active window' by then).
I strongly suspect the culprit is some ESS background process -- happening accidentally not in the background -- which takes much longer than for average people: I have ca 20'000 R packages in my
.libPaths()
libraries (all of CRAN (apart from a few dozen I can't easily install), plus a 100 Bioconductore, ..).If ESS gets the silly idea that it should prepare completion for all of these namespaces and does so not really in the background .. this is explains which I'm seeing.
Yes, I've also changed my startup back to my previous default of not having tracebug active.
But that is improbably as cause, or .. ???
The text was updated successfully, but these errors were encountered: