zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
21.33k stars 644 forks source link

Panic in thread `pty_writer` when starting Zellij on FreeBSD #2876

Open ThomasFrans opened 1 year ago

ThomasFrans commented 1 year ago
`zellij.log` ``` WARN |zellij_utils::input::layo| 2023-10-19 11:08:43.952 [main ] [zellij-utils/src/input/layout.rs:962]: Failed to read swap layout file: /home/thomas/.config/zellij/layouts/default.swap.kdl. Error: Os { code: 2, kind: NotFound, message: "No such file or directory" } INFO |zellij_client | 2023-10-19 11:08:43.958 [main ] [zellij-client/src/lib.rs:152]: Starting Zellij client! INFO |zellij_server | 2023-10-19 11:08:43.966 [main ] [zellij-server/src/lib.rs:245]: Starting Zellij server! INFO |zellij_server | 2023-10-19 11:08:44.023 [main ] [zellij-server/src/lib.rs:913]: Compiling plugins using Cranelift INFO |zellij_server::plugins | 2023-10-19 11:08:44.024 [wasm ] [zellij-server/src/plugins/mod.rs:137]: Wasm main thread starts ERROR |zellij_client::stdin_ansi| 2023-10-19 11:08:44.025 [stdin_handler] [zellij-client/src/stdin_ansi_parser.rs:94]: Failed to open STDIN cache file: Os { code: 2, kind: NotFound, message: "No such file or directory" } ERROR |zellij_utils::errors::not| 2023-10-19 11:08:44.063 [pty_writer] [zellij-utils/src/errors.rs:614]: Panic occured: thread: pty_writer location: At /wrkdirs/usr/ports/sysutils/zellij/work/zellij-0.38.2/cargo-crates/anyhow-1.0.71/src/backtrace.rs:264:19 message: range start index 2 out of range for slice of length 1 WARN |zellij_utils::ipc | 2023-10-19 11:08:44.117 [router ] [zellij-utils/src/ipc.rs:222]: Error in IpcReceiver.recv(): InvalidMarkerRead(Error { kind: UnexpectedEof, message: "failed to fill whole buffer" }) ERROR |zellij_client | 2023-10-19 11:08:44.117 [router ] [zellij-client/src/lib.rs:348]: Received empty message from server ```

Basic information

zellij --version: zellij 0.38.2 stty size: 45 192 uname -av or ver(Windows): FreeBSD thomas-vm-freebsd 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64

Further information I created a FreeBSD VM for development and copied all my config files to it, including the ones for Zellij. When I start Zellij however, it panics immediately and writes some info to the log.

I tried running Zellij as the root user without any config files, and it works. The config also works on my Linux machine, so I don't think there is anything wrong with that.

imsnif commented 1 year ago

Hey, thanks for the report and sorry for the experience. Unfortunately the log doesn't give us a lot of info to go on. Would you like to maybe troubleshoot this a little bit further to find out what's causing the issue? eg. running as root with your config? running without root and with the default config? I don't know your system (or a lot about freebsd tbh), so would appreciate your help here. Thanks!

ThomasFrans commented 1 year ago

Of course! I wanted to provide more info as the logs indeed aren't all that detailed, but didn't really know what to provide. I'll test these things and see what works and provide logs for things that don't work.

As for the FreeBSD install, it's a completely fresh install so not much has changed from the defaults (except my config files being installed). I don't know much about FreeBSD either. First time using it, so thought I could at least get Zellij installed to help with the experience :smile:

ThomasFrans commented 1 year ago
Running `zellij` as the regular user sometimes displays this ``` Error occurred in server: × Thread 'pty_writer' panicked. ├─▶ Originating Thread(s) │ 1. ipc_server: NewClient │ 2. screen_thread: NewTab │ 3. plugin_thread: NewTab │ 4. pty_thread: NewTab │ 5. screen_thread: ApplyLayout │ 6. pty_writer_thread: ApplyCachedResizes │ ├─▶ At /wrkdirs/usr/ports/sysutils/zellij/work/zellij-0.38.2/cargo-crates/anyhow-1.0.71/src/backtrace.rs:264:19 ╰─▶ range start index 2 out of range for slice of length 1 Panic backtrace: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: help: If you are seeing this message, it means that something went wrong. -> To get additional information, check the log at: /tmp/zellij-1001/zellij-log/zellij.log -> To see a backtrace next time, reproduce the error with: RUST_BACKTRACE=1 zellij [...] -> To help us fix this, please open an issue: https://github.com/zellij-org/zellij/issues ```

It seems like an indexing problem from looking at the output here...

Running zellij --config-dir='/home/thomas/.config/zellij as the root user worked once, after that it hangs every time, even without --config-dir set. I tried clearing the root user's cache for Zellij. I tried closing and reopening the session. The problem persists.

If it helps I could run a debug build to get a better backtrace?

Edit 1: The problem where the root user couldn't start a Zellij session anymore seems to have been caused by the previous session not being terminated correctly. I noticed the fans on my laptop spinning so looked what was going on and Zellij in the VM was spiking CPU usage on one core. It didn't react to SIGTERM anymore.

imsnif commented 1 year ago

This is in all likelihood a permission issue on the socket dir (just guessing, since most of these errors originate from ipc handling). The rest of the logs can be misleading because they represent different parts of the app reacting to one of the threads crashing.

imsnif commented 1 year ago

The socket dir btw should be: XDG_RUNTIME_DIR

ThomasFrans commented 1 year ago

This is in all likelihood a permission issue on the socket dir (just guessing, since most of these errors originate from ipc handling). The rest of the logs can be misleading because they represent different parts of the app reacting to one of the threads crashing.

I think on FreeBSD the runtime directory isn't the same as on Linux /run/user/<uid>. I see that Zellij created a directory under /tmp called zellij-1001 which has permissions 0700. Those permissions should be the exact same as the /run/user/<uid> runtime directory on Linux so I don't exactly understand how it could be a permission issue.

The XDG_RUNTIME_DIR variable isn't set, but Zellij seems to create the runtime directory under /tmp as a fallback so I don't think the variable not being there is an issue.

imsnif commented 1 year ago

It could also be a permission issue creating and writing to PTY's... but other than hacking together a small program that does the openpty syscall and tried to write some stuff to it I don't have a lot of ideas.

ThomasFrans commented 1 year ago

I'll see whether I can do something like that when I have some spare time.