wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.35k stars 724 forks source link

Wezterm panic: called `Option::unwrap()` on a `None` value #5518

Open mamaraddio opened 2 months ago

mamaraddio commented 2 months ago

What Operating System(s) are you seeing this problem on?

Linux Wayland

Which Wayland compositor or X11 Window manager(s) are you using?

Hyprland

WezTerm version

wezterm 20240603-194616-e4b18c41

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Wezterm panics when closing with exit and does not cleanup $XDG_RUNTIME_DIR/wezterm

To Reproduce

Configuration

Wezterm config ```lua local config = {} if wezterm.config_builder then config = wezterm.config_builder() end local fonts = { ... } local emoji_fonts = { ... } for _, gpu in ipairs(wezterm.gui.enumerate_gpus()) do if gpu.backend == "Vulkan" and (gpu.device_type == "IntegratedGpu" or gpu.device_type == "DiscreteGpu") then config.webgpu_preferred_adapter = gpu config.front_end = "WebGpu" -- WebGpu | OpenGL | Software break end end config = { enable_wayland = false, font = wezterm.font_with_fallback({ fonts[2], emoji_fonts[1], emoji_fonts[2], }), freetype_load_flags = "FORCE_AUTOHINT", font_size = 12, use_fancy_tab_bar = false, window_decorations = "NONE", hide_tab_bar_if_only_one_tab = true, window_background_opacity = 0.75, default_cursor_style = "BlinkingBar", window_padding = { left = 5, right = 5, top = 5, bottom = 5 }, color_scheme = "Dark Pastel", set_environment_variables = { PATH = os.getenv("PATH"), }, } return config ```

Expected Behavior

To close without die and (maybe) it should cleanup $XDG_RUNTIME_DIR/wezterm (?)

Logs

Wezterm logs ```rs 17:47:09.135 ERROR env_bootstrap > panic at mux/src/lib.rs:752:25 - called `Option::unwrap()` on a `None` value 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: ```

Anything else?

Content of $XDG_RUNTIME_DIR/wezterm after panic ```sh srwx-----T 1 user group 0 5 giu 17.47 gui-sock-179118 -rw-r--r-- 1 user group 339 5 giu 17.47 wezterm-gui-log-179118.txt lrwxrwxrwx 1 user group 38 5 giu 17.47 x11-:0-org.wezfurlong.wezterm -> /run/user/1000/wezterm/gui-sock-179118 ```
BACKTRACE=full ```rs RUST_BACKTRACE=full wezterm start libEGL warning: egl: failed to create dri2 screen 17:41:35.960 ERROR env_bootstrap > panic at mux/src/lib.rs:752:25 - called `Option::unwrap()` on a `None` value 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: thread '' panicked at mux/src/lib.rs:752:25: called `Option::unwrap()` on a `None` value stack backtrace: 0: 0x64d4f658fbe2 - 1: 0x64d4f65c3cec - 2: 0x64d4f6589baf - 3: 0x64d4f658f9b4 - 4: 0x64d4f65916eb - 5: 0x64d4f6591443 - 6: 0x64d4f4b695f3 - 7: 0x64d4f6591d90 - 8: 0x64d4f6591a99 - 9: 0x64d4f65900b6 - 10: 0x64d4f6591804 - 11: 0x64d4f65c0bb5 - 12: 0x64d4f65c0c73 - 13: 0x64d4f65c0946 - 14: 0x64d4f5510843 - 15: 0x64d4f555ed39 - 16: 0x64d4f558065d - 17: 0x64d4f6598605 - 18: 0x7bdf0f8a6ded - 19: 0x7bdf0f92a0dc - 20: 0x0 - zsh: segmentation fault (core dumped) RUST_BACKTRACE=full wezterm start ```
mbwilding commented 2 months ago

Version: wezterm 20240603-194616-e4b18c41 OS: Linux Distro: Arch DE: KDE Plasma 6 Compositor: Wayland

Same issue on exit. mux/src/lib.rs:752:25

image

mbwilding commented 1 month ago

Still happening in: wezterm 20240624-065522-552bb1d6

Doesn't help that Mux::get is just Mux::try_get with an unwrap.

garcialn commented 1 month ago

Version: wezterm 20240624-065522-552bb1d6 OS: Linux Distro: PopOS DE: GNOME/Cosmic Compositor: X11

Same issue.

ozelentok commented 1 month ago

Recompiled with stripping disabled Version: wezterm 20240701-070926-69686f45 Distro: Arch WM: i3wm Compositor: X11

RUST_BACKTRACE=full wezterm start
23:46:35.036  ERROR  env_bootstrap > panic at mux/src/lib.rs:752:25 - called `Option::unwrap()` on a `None` value
   0: env_bootstrap::register_panic_hook::{{closure}}
   1: std::panicking::rust_panic_with_hook
   2: std::panicking::begin_panic_handler::{{closure}}
   3: std::sys_common::backtrace::__rust_end_short_backtrace
   4: rust_begin_unwind
   5: core::panicking::panic_fmt
   6: core::panicking::panic
   7: core::option::unwrap_failed
   8: mux::Mux::get
   9: mux::ssh_agent::AgentProxy::process_updates
  10: std::sys_common::backtrace::__rust_begin_short_backtrace
  11: core::ops::function::FnOnce::call_once{{vtable.shim}}
  12: std::sys::pal::unix::thread::Thread::new::thread_start
  13: <unknown>
  14: <unknown>

thread '<unnamed>' panicked at mux/src/lib.rs:752:25:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x5f2be9e60df5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h367d587903c05733
   1:     0x5f2be9e9179b - core::fmt::write::h90d6c7093938e590
   2:     0x5f2be9e5b2ef - std::io::Write::write_fmt::hf166be129b5ac403
   3:     0x5f2be9e60bce - std::sys_common::backtrace::print::h16f4e54dda428f87
   4:     0x5f2be9e625c9 - std::panicking::default_hook::{{closure}}::h421dd5e2264b9ca7
   5:     0x5f2be9e6230d - std::panicking::default_hook::hd6ec143ee36c91c5
   6:     0x5f2be8518ede - env_bootstrap::register_panic_hook::{{closure}}::h997826af2e570241
   7:     0x5f2be9e62b96 - std::panicking::rust_panic_with_hook::he0e1ddfdd1ef8a31
   8:     0x5f2be9e6290b - std::panicking::begin_panic_handler::{{closure}}::h75fca2fc3c1ec62d
   9:     0x5f2be9e612b9 - std::sys_common::backtrace::__rust_end_short_backtrace::h9d480d72ed19fe3c
  10:     0x5f2be9e62677 - rust_begin_unwind
  11:     0x5f2be8131173 - core::panicking::panic_fmt::h10c3ee83b4e55229
  12:     0x5f2be813121c - core::panicking::panic::hc7fabc0ebcde9e37
  13:     0x5f2be8131119 - core::option::unwrap_failed::h22e9dd776357f2b9
  14:     0x5f2be8f26568 - mux::Mux::get::hfb5a213cdebaf1bf
  15:     0x5f2be8f1e736 - mux::ssh_agent::AgentProxy::process_updates::h879dda39facadb58
  16:     0x5f2be8ec3456 - std::sys_common::backtrace::__rust_begin_short_backtrace::hea567e6848f35912
  17:     0x5f2be8ed728f - core::ops::function::FnOnce::call_once{{vtable.shim}}::h20f34d9a56439f90
  18:     0x5f2be9e699bb - std::sys::pal::unix::thread::Thread::new::thread_start::ha6a84773a   e141289
  19:     0x7eb6648a6ded - <unknown>
  20:     0x7eb66492a0dc - <unknown>                                                            
  21:                0x0 - <unknown>

Once I set mux_enable_ssh_agent = false in the configuration, the error did not appear again.

wez commented 1 month ago

This should be resolved now in main.

It typically takes about an hour before commits are available as nightly builds for all platforms. Linux builds are the fastest to build and are often available within about 20 minutes. Windows and macOS builds take a bit longer.

Please take a few moments to try out the fix and let me know how that works out. You can find the nightly downloads for your system in the wezterm installation docs.

If you prefer to use packages provided by your distribution or package manager of choice and don't want to replace that with a nightly download, keep in mind that you can download portable packages (eg: a .dmg file on macOS, a .zip file on Windows and an .AppImage file on Linux) that can be run without permanently installing or replacing an existing package, and can then simply be deleted once you no longer need them.

If you are eager and can build from source then you may be able to try this out more quickly.

mbwilding commented 1 month ago

Just built main and did a quick test with the aforementioned mux_enable_ssh_agent setting removed from my config. Seems good now, thanks @wez. If anything changes, I will report back.

garcialn commented 1 month ago

Updated to Wezterm Nightly -v 20240714-110354-b20c6192 and the issue no longer persists. Thank you, @wez 😄

rengare commented 1 week ago

why also not fix this: image

Before: image

Since self.surface_to_pending returns Option and the function returns None, it could return None when there is no active_surface.

I can create PR since I have that change.