-
Notifications
You must be signed in to change notification settings - Fork 331
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
Bug: lf crashes when shell command is run in config file #1659
Comments
Thanks very much for the bug report. I did not consider the scenario where shell commands are scripted from the config file - these will be run before Certain operations don't make sense to run before diff --git a/app.go b/app.go
index e58acbf..717660a 100644
--- a/app.go
+++ b/app.go
@@ -484,7 +484,9 @@ func (app *app) runCmdSync(cmd *exec.Cmd, pause_after bool) {
app.ui.loadFile(app, true)
//mark the current directory as updated for refresh
- app.nav.currDir().updated = true
+ if app.nav.init {
+ app.nav.currDir().updated = true
+ }
app.nav.renew()
} But after thinking about the problem some more, I am starting to think that reloading the current directory like this isn't a good solution for a few reasons:
This kind of problem is not trivial to fix, and I think it requires further discussion. Instead of the above solution, I prefer to have either:
For the time being, since there is an upcoming release, I will revert #1638 as crashes can't be tolerated. Thanks once again for raising this. |
This is fixed now since I reverted the commit, cc @gokcehan |
@joelim-work The dircache condition you suggested looks like a good solution to me and since the updated variable does not itself trigger checkDir, I am not sure where you see the remaining threading issue. It may set the wrong directory to be updated in some cases but this should still be safe, right? Still a bug for those edge cases but in most scenarios it solves the issue. To fully solve all issues with file changes, I think there isn't really a good alternative to using https://github.com/fsnotify/fsnotify, especially not without performance costs. That may be something to be revisited by @gokcehan eventually. If at all possible I would like to get a fixed version of #1638 into the next release even if there may be a better solution in the future. |
@valoq I would be happy to see a fixed version of the patch. Note, I was thinking of releasing r32 tomorrow or the day after that, so the patch might only be included in r33 onwards if that's ok. Or alternatively, we can delay the release further if people think it is worth including this patch in the release. Regarding fsnotify, I'm ready to revisit the idea if someone comes up with a patch. However, I think the problem is that it may not be trivial to come up with such a patch, and at this point we are not sure if it is going to solve all our issues. There are simply too many different cases that users report as issues (e.g. permission changes, various filesystem mounts, directory counts, previews), so I'm not sure fsnotify will be able to handle all cases. In that case, we would need to maintain our use of fsnotify in addition to all the existing issues that we are getting reported. @joelim-work I forgot if you shared your opinion somewhere before, but what do you think of fsnotify in general? |
@valoq @gokcehan As a quick fix, I think it is fine to the merge the initial patch for #1638, namely this commit, as it doesn't have anything to do with the crash when running shell commands upon startup. But I still see it as only a half-solution (but kind of good enough) with limitations, and I wouldn't surprised if there are further issues, in addition to what I mentioned above in #1659 (comment). For instance I discovered that this won't work when you copy from one instance to another - only the active instance will be updated, which makes sense as the On the topic of This is the work I have so far for |
When running shell commands in the config file, lf immediately crashes upon startup. To replicate I have created a simple lfrc, only containing one command:
(Using
!echo "Hello World"
also works, but%echo "Hello World"
and&echo "Hello World"
do not produce any issues.)lf crashes immediately with the following output:
A quick git bisect showed that the bug only appears after the recent #1638 PR. (Tagging @valoq @joelim-work, since they both discussed this PR.)
I haven't looked into the issue much yet, but it appears as if the
nav.dirs
array is empty during the initialization, causing thecurrDir()
function to panic. I think the issue is probably the change in therunCmdSync()
function. A quick fix would be to simply check ifnav.dirs
contains elements before calling thecurrDir()
function or to have thecurrDir()
function return a null pointer and then check the result of the call in therunCmdSync()
, before setting the parameter. But I'm not too familiar with the code anymore, so there may be better solutions, that I'm not aware of. (Like loading the current directory before parsing the configuration file.)The text was updated successfully, but these errors were encountered: