vamolessa / pepper

simple and opinionated modal code editor for your terminal
https://vamolessa.github.io/pepper/
373 stars 15 forks source link

Pasting 100 characters crashes pepper #7

Closed leahneukirchen closed 3 years ago

leahneukirchen commented 3 years ago

Use an empty buffer, insert mode, paste this string of 100 x: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.

Pepper crashes:

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 14', src/client.rs:276:23
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3e99439f4dacc8ba0d2ca48d221694362d587927/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/3e99439f4dacc8ba0d2ca48d221694362d587927/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/3e99439f4dacc8ba0d2ca48d221694362d587927/library/core/src/panicking.rs:69:5
   3: pepper::command::CommandManager::eval_and_then_output
   4: pepper::editor::Editor::on_client_event
   5: pepper::application::ServerApplication::run_application

Reproducible on pepper 1e231e3535e08b2d81.

vamolessa commented 3 years ago

Wow, it seems that this input triggers some degenerate case on fuzzy_match (src/picker.rs). Will work on that later!

leahneukirchen commented 3 years ago

I have config completion_min_len 255 if that matters.

vamolessa commented 3 years ago

Wait, are you saying that you got that crash even when using config completion_min_len 255? Or rather that you're using it that config as a workaround?

vamolessa commented 3 years ago

Oh, I just noticed that it only happens on wsl!

leahneukirchen commented 3 years ago

I noticed it with (I added it to disable the completion).

I use native Linux.

vamolessa commented 3 years ago

Got the crash fixed! It was because we were incorrectly deserializing client events when the stdin_buf was not big enough to hold all the incomming events.

The fuzzy_match being extremelly slow is still there as it will require implementing a better algorithm. I'll create a new issue for it and close this one!