Lyude / neovim-gtk

gtk ui for neovim
GNU General Public License v3.0
156 stars 9 forks source link

Random crash on sudden navigation #112

Closed baco closed 2 months ago

baco commented 4 months ago

Describe the bug Having a lot of opened files in tabs (my current setup involves 45 files in tabs, but it started happening some point before), most of the files having the extra processing of LSP servers running on them; when navigating one file, up-and-down, in a fast fashion (that is scrolling a file of 500+ lines instead of jumping to a specific line directly) makes the GTK-UI crash.

The crash is somehow located around nvim/ext.rs:53 because of an optimistic error handling (.unwrap()) that may result in an error, for which .unwrap() panics if self was an Err.

Handling the previous case, like not doing anything but at least not panicking:

    fn ok_and_report(self) -> Option<T> {
        self.report_err();
        match self {
            Ok(msg) => Some(msg),
            Err(_) => None,
        }
    }

moves the error (the panic) to another module, also optimistically handling errors.

The new error, if handling the previous one as above, arises in src/input.rs:100 (.expect()). Again an optimistic error handling, expecting that .ok_and_report() will not result in an error, which wasn't happening because the called function was panicking instead of returning an error. Also an error occurs in src/input.rs:88 when calling the same function as before (.ok_and_report()) from another location in code.

Couldn't reproduced it with less load (less than 20 files of less than couple of hundred of lines each), but it is consistent when having such a big amount of files opened, and LSP servers running on them.

Technical information (please complete the following information):

Lyude commented 3 months ago

This looks like an annoying enough bug I'll try to take a look at this asap, I'm a little surprised i haven't run into this one myself owo

Lyude commented 3 months ago

Ok - this is weird, I think I might need to refresh myself on how to get neovim to dump more information because I'm fairly sure that input events are never something that should fail (unless this behavior has changed in neovim at some point?). If you drop the .expect() in src/input.rs does the session still work properly afterwards?

Lyude commented 3 months ago

I think for the time being I might just make this not panic - dropping a key press is probably preferable to a panic (even though in theory we aren't supposed to be hitting this code, bugs are always possible)