Skip to content
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

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

Open
mamaraddio opened this issue Jun 5, 2024 · 8 comments
Open

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

mamaraddio opened this issue Jun 5, 2024 · 8 comments
Labels
bug Something isn't working fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds.

Comments

@mamaraddio
Copy link

mamaraddio commented Jun 5, 2024

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 mamaraddio added the bug Something isn't working label Jun 5, 2024
@mbwilding
Copy link

mbwilding commented Jun 7, 2024

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
Copy link

mbwilding commented Jun 28, 2024

Still happening in: wezterm 20240624-065522-552bb1d6

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

@garcialn
Copy link

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

Same issue.

@ozelentok
Copy link

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
Copy link
Owner

wez commented Jul 13, 2024

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 wez added the fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds. label Jul 13, 2024
saep pushed a commit to saep/wezterm that referenced this issue Jul 14, 2024
@mbwilding
Copy link

mbwilding commented Jul 14, 2024

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
Copy link

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

@rengare
Copy link
Contributor

rengare commented Aug 14, 2024

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 added a commit to rengare/wezterm that referenced this issue Aug 21, 2024
wez added a commit that referenced this issue Sep 14, 2024
* #5518: handling panic in copy_and_paste.rs line 105

Co-authored-by: Wez Furlong <[email protected]>
wez added a commit that referenced this issue Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed-in-nightly This is (or is assumed to be) fixed in the nightly builds.
Projects
None yet
Development

No branches or pull requests

6 participants