Copy hash freeze gitui
Describe the bug When I copy the hash of a commit on gitui. It crashes. But it copies the hash well.
To Reproduce Steps to reproduce the behavior:
- Open gitui
- go to log tab
- Press y
- and gitui freeze
Context (please complete the following information):
- Debian 11, kernel 5.10.0-20-amd64
- gnome 3.38 (Wayland)
- GitUI Version : 0.22.1
- Rust version: 1.65.0
- wl-clipboard : 2.0.0
please share the log after the freeze
When i write gitui -l and I reproduce the bug.
Gitui don't create log file and just freeze to infinity
I can see this as well and tried to look at what happens using gdb. When I copy the hash gdb displays the following:
[Detaching after vfork from child process 2735066]
gitui then freezes. If I dump the stack trace it seems like the main thread is waiting for a read:
(gdb) bt
#0 __GI___libc_read (nbytes=32, buf=0x560534b07f30, fd=13) at ../sysdeps/unix/sysv/linux/read.c:26
#1 __GI___libc_read (fd=13, buf=0x560534b07f30, nbytes=32) at ../sysdeps/unix/sysv/linux/read.c:24
#2 0x00005605336a8f3a in std::sys::unix::fd::FileDesc::read () at library/std/src/sys/unix/fd.rs:79
#3 std::sys::unix::pipe::AnonPipe::read () at library/std/src/sys/unix/pipe.rs:49
#4 std::process::{impl#16}::read () at library/std/src/process.rs:415
#5 std::io::Read::read_buf::{closure#0}<std::process::ChildStderr> () at library/std/src/io/mod.rs:812
#6 std::io::default_read_buf<std::io::Read::read_buf::{closure_env#0}<std::process::ChildStderr>> () at library/std/src/io/mod.rs:468
#7 std::io::Read::read_buf<std::process::ChildStderr> () at library/std/src/io/mod.rs:812
#8 std::io::default_read_to_end<std::process::ChildStderr> () at library/std/src/io/mod.rs:372
#9 std::io::Read::read_to_end<std::process::ChildStderr> () at library/std/src/io/mod.rs:703
#10 std::process::Child::wait_with_output () at library/std/src/process.rs:1982
#11 0x00005605335007ec in gitui::clipboard::exec_copy_with_args ()
#12 0x0000560533500c79 in gitui::clipboard::copy_string ()
#13 0x000056053353bd9c in <gitui::tabs::revlog::Revlog as gitui::components::Component>::event ()
#14 0x000056053352ac8a in gitui::components::event_pump ()
#15 0x000056053354c612 in gitui::run_app ()
#16 0x00005605335490e1 in gitui::main ()
#17 0x00005605334b8c68 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
#18 0x000056053355b313 in main ()
Without having looked at the code, I'd guess that maybe the child process invoked to copy to the clipboard crashed or did not run and the main thread is waiting for its status or output with a blocking read that never returns?
I am unable to reproduce this, would need help figuring that one out or how to reproduce on a Mac or in some docker container. volunteers?
Hallo @extrawurst
The reproduction is straightforward.
- Run any container
sudo docker run -ti --rm archlinux /bin/bash - install gitui and git
pacman -Sy
pacman -S git gitui
- configure git with some global setting, init a repo, add some commit.
git config --global user.email "[email protected]"
git config --global user.name "asdf"
git init
git commit -m "test message" --allow-empty
- And as issue desctiption says: run gitui, switch to logs tab and press y.
Hello,
I think the problem only happens when xclip is installed.
-
If you only have
xselinstalled (withoutxclip), the copy works. -
If you have
xclipinstalled, with or withoutxsel, it freezes. -
If you have neither of
xcliporxselinstalled, you have this message:
Failed to copy text
`"xsel"`: No such file or directory (os error 2)
Run any container sudo docker run -ti --rm archlinux /bin/bash
unfortunately does not work on arm64 mac :(
docker: no matching manifest for linux/arm64/v8 in the manifest list entries
@quentin-bettoum Uninstalling xclip worked for me. Thanks.
@extrawurst, any ideas as to why having xclip installed causes this? Does gitui also try to use xclip?
@AnonymouX47 yeah on unix systems it tries to use xclip, if that is not found it uses xsel checkout cad40d1 for when this was introduced
Is it possible to update Readme/documentation to mention this xclip/xsel problem on linux systems?
Or better yet, use some rust crate that deals with clipboard?
@extrawurst I see, thanks.
related: https://github.com/extrawurst/gitui/pull/1586
For context: the root cause of this class of crash is a .unwrap() inside std::process::Command::wait_with_output() in the Rust standard library. When the child process pipe becomes unreadable, the stdlib panics instead of returning an error.
PR #1586 works around it at the gitui level, but the stdlib bug remains on main. I have a fix with a regression test at SebTardif/rust#428 that replaces the .unwrap() with ? so wait_with_output() returns Err instead of panicking.
If anyone hits a similar freeze/crash with a different child process, that is likely the same root cause.