wezterm icon indicating copy to clipboard operation
wezterm copied to clipboard

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

Open mamaraddio opened this issue 1 year ago • 3 comments

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

  • Open wezterm
  • Run the exit command

Configuration

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

Anything else?

Content of $XDG_RUNTIME_DIR/wezterm after panic
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
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: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>

thread '<unnamed>' panicked at mux/src/lib.rs:752:25:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x64d4f658fbe2 - <unknown>
   1:     0x64d4f65c3cec - <unknown>
   2:     0x64d4f6589baf - <unknown>
   3:     0x64d4f658f9b4 - <unknown>
   4:     0x64d4f65916eb - <unknown>
   5:     0x64d4f6591443 - <unknown>
   6:     0x64d4f4b695f3 - <unknown>
   7:     0x64d4f6591d90 - <unknown>
   8:     0x64d4f6591a99 - <unknown>
   9:     0x64d4f65900b6 - <unknown>
  10:     0x64d4f6591804 - <unknown>
  11:     0x64d4f65c0bb5 - <unknown>
  12:     0x64d4f65c0c73 - <unknown>
  13:     0x64d4f65c0946 - <unknown>
  14:     0x64d4f5510843 - <unknown>
  15:     0x64d4f555ed39 - <unknown>
  16:     0x64d4f558065d - <unknown>
  17:     0x64d4f6598605 - <unknown>
  18:     0x7bdf0f8a6ded - <unknown>
  19:     0x7bdf0f92a0dc - <unknown>
  20:                0x0 - <unknown>
zsh: segmentation fault (core dumped)  RUST_BACKTRACE=full wezterm start

mamaraddio avatar Jun 05 '24 15:06 mamaraddio

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 avatar Jun 07 '24 00:06 mbwilding

Still happening in: wezterm 20240624-065522-552bb1d6

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

mbwilding avatar Jun 28 '24 03:06 mbwilding

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

Same issue.

garcialn avatar Jun 28 '24 18:06 garcialn

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.

ozelentok avatar Jul 10 '24 21:07 ozelentok

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.

wez avatar Jul 13 '24 22:07 wez

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.

mbwilding avatar Jul 14 '24 12:07 mbwilding

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

garcialn avatar Jul 14 '24 22:07 garcialn

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.

rengare avatar Aug 14 '24 10:08 rengare