daa84 / neovim-gtk

gtk ui for neovim
GNU General Public License v3.0
718 stars 56 forks source link

Actions from the Gnome toolbar require double-click when other Gnome apps work just with single-click #69

Closed mcepl closed 6 years ago

mcepl commented 6 years ago

It looks really lovely how nvim-gtk (build by myself from the commit 3c74351 ) sports the same toolbar and general design (outside of the editing area proper) very same as other Gnome applications (namely GEdit). Unfortunately, I cannot open a file using either method from the Gnome dialog (normal e: filename command works fine). When I either select a file from the list of the last used files, or from "Other documents" dialog, the dialog doesn't close and neovim-gtk stops accepting any input.

When I got program frozen in gdb, I interrupted it with <Ctrl-C> and collected this backtrace:

matej@mitmanek: ~$ gdb nvim-gtk
GNU gdb (GDB) Red Hat Enterprise Linux 8.0-17.1.scylladb.1.el7.centos
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from nvim-gtk...done.
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /home/matej/archiv/knihovna/repos/neovim-gtk/target/debug/nvim-gtk.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) run
Starting program: /home/matej/.local/bin/nvim-gtk 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffe5662700 (LWP 1870)]
[New Thread 0x7fffe4e61700 (LWP 1871)]
[New Thread 0x7fffdffff700 (LWP 1873)]
[New Thread 0x7fffdf15c700 (LWP 1875)]
[New Thread 0x7fffde95b700 (LWP 1877)]
[New Thread 0x7fffdd76c700 (LWP 1881)]
Detaching after fork from child process 1882.
[New Thread 0x7fffdd56b700 (LWP 1883)]
[New Thread 0x7fffdd36a700 (LWP 1885)]
[Thread 0x7fffdd76c700 (LWP 1881) exited]
[Thread 0x7fffde95b700 (LWP 1877) exited]
^C
Thread 8 "nvim-gtk" received signal SIGINT, Interrupt.
[Switching to Thread 0x7fffdd56b700 (LWP 1883)]
0x0000555555972d7c in termcolor::ColorChoice::should_attempt_color (self=0x7fffdd5695ef)
    at /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/termcolor-0.3.4/src/lib.rs:137
137             ColorChoice::Always => true,
(gdb) t a a bt

Thread 9 (Thread 0x7fffdd36a700 (LWP 1885)):
#0  0x00007ffff5914f47 in pthread_join (threadid=140736906835712, thread_return=0x0)
    at pthread_join.c:92
#1  0x00005555559ab8b0 in std::sys::unix::thread::Thread::join (self=...)
    at src/libstd/sys/unix/thread.rs:176
#2  0x00005555555a1c3d in <std::thread::JoinInner<T>>::join (self=0x7fffdd369560)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/thread/mod.rs:1200
#3  0x00005555555a1ca8 in <std::thread::JoinHandle<T>>::join (self=...)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/thread/mod.rs:1322
#4  0x0000555555769b27 in nvim_gtk::shell::init_nvim_async::{{closure}} ()
    at src/shell.rs:847
#5  0x0000555555742b63 in std::sys_common::backtrace::__rust_begin_short_backtrace (f=...)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/sys_common/backtrace.rs:133
#6  0x00005555555a1bf7 in std::thread::Builder::spawn::{{closure}}::{{closure}} ()
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/thread/mod.rs:406
#7  0x00005555556cb303 in <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once (self=..., _args=())
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/panic.rs:300
#8  0x000055555565426e in std::panicking::try::do_call (data=0x7fffdd3697d8 "\001")
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/panicking.rs:480
#9  0x00005555559cbf5f in __rust_maybe_catch_panic (f=0xfffffffffffffe00, data=0x7fffdd56b9d0 "[\a", data_ptr=0x7fffdd3697c8, vtable_ptr=0x7fffdd3697d0)
    at src/libpanic_unwind/lib.rs:101
#10 0x000055555565408a in std::panicking::try (f=...)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/panicking.rs:459
#11 0x00005555556cb508 in std::panic::catch_unwind (f=...)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/panic.rs:365
#12 0x00005555555a0878 in std::thread::Builder::spawn::{{closure}} ()
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/thread/mod.rs:405
#13 0x00005555555a1e98 in <F as alloc::boxed::FnBox<A>>::call_box (self=0x7fffc4000df0, args=()) at /builddir/build/BUILD/rustc-1.24.0-src/src/liballoc/boxed.rs:815
#14 0x00005555559b5438 in _$LT$alloc..boxed..Box$LT$alloc..boxed..FnBox$LT$A$C$$u20$Output$u3d$R$GT$$u20$$u2b$$u20$$u27$a$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::hc4b7698d3dffd34f (self=<error reading variable: access outside bounds of object referenced via synthetic pointer>, args=<optimized out>)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/liballoc/boxed.rs:825
#15 0x00005555559b5438 in std::sys_common::thread::start_thread (main=0x7fffc4000e70 "\360\r") at src/libstd/sys_common/thread.rs:24
#16 0x00005555559ab739 in std::sys::unix::thread::Thread::new::thread_start (main=0x7fffdd56b9d0) at src/libstd/sys/unix/thread.rs:90
#17 0x00007ffff5913dd5 in start_thread (arg=0x7fffdd36a700) at pthread_create.c:308
#18 0x00007ffff5427b3d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 8 (Thread 0x7fffdd56b700 (LWP 1883)):
#0  0x0000555555972d7c in termcolor::ColorChoice::should_attempt_color (self=0x7fffdd5695ef)
    at /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/termcolor-0.3.4/src/lib.rs:137
#1  0x0000555555973965 in termcolor::Buffer::new (choice=termcolor::ColorChoice::Auto)
    at /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/termcolor-0.3.4/src/lib.---Type <return> to continue, or q <return> to quit---
rs:756
#2  0x0000555555973250 in termcolor::BufferWriter::buffer (self=0x555555e59270)
    at /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/termcolor-0.3.4/src/lib.rs:679
#3  0x0000555555873c97 in env_logger::fmt::Formatter::new (writer=0x555555e59270)
    at /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.5.3/src/fmt.rs:408
#4  0x0000555555852a2d in <env_logger::Logger as log::Log>::log::{{closure}} (tl_buf=0x7fffdd56b610)
    at /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.5.3/src/lib.rs:494
#5  0x000055555585b953 in <std::thread::local::LocalKey<T>>::try_with (self=0x555555e3a6c0, f=...) at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/thread/local.rs:377
#6  0x000055555585b795 in <std::thread::local::LocalKey<T>>::with (self=0x555555e3a6c0, f=...) at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/thread/local.rs:288
#7  0x000055555585284d in <env_logger::Logger as log::Log>::log (self=0x555555e59270, record=0x7fffdd569e00)
    at /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/env_logger-0.5.3/src/lib.rs:471
#8  0x0000555555707749 in <neovim_lib::rpc::client::Client<R, W>>::dispatch_thread::{{closure}} () at <log macros>:5
#9  0x0000555555742ad3 in std::sys_common::backtrace::__rust_begin_short_backtrace (f=...)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/sys_common/backtrace.rs:133
#10 0x00005555555a1a97 in std::thread::Builder::spawn::{{closure}}::{{closure}} ()
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/thread/mod.rs:406
#11 0x00005555556cb283 in <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once (self=..., _args=())
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/panic.rs:300
#12 0x000055555565438d in std::panicking::try::do_call (data=0x7fffdd56a838 "\020\r\000")
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/panicking.rs:480
#13 0x00005555559cbf5f in __rust_maybe_catch_panic (f=0x555555a148b4, data=0x2 <error: Cannot access memory at address 0x2>, data_ptr=0x7fffdd56a828, vtable_ptr=0x7fffdd56a830)
    at src/libpanic_unwind/lib.rs:101
#14 0x0000555555653d99 in std::panicking::try (f=...)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/panicking.rs:459
#15 0x00005555556cb41a in std::panic::catch_unwind (f=...)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/panic.rs:365
#16 0x00005555555a0d77 in std::thread::Builder::spawn::{{closure}} ()
    at /builddir/build/BUILD/rustc-1.24.0-src/src/libstd/thread/mod.rs:405
#17 0x00005555555a1d80 in <F as alloc::boxed::FnBox<A>>::call_box (self=0x7fffc4001100, args=()) at /builddir/build/BUILD/rustc-1.24.0-src/src/liballoc/boxed.rs:815
#18 0x00005555559b5438 in _$LT$alloc..boxed..Box$LT$alloc..boxed..FnBox$LT$A$C$$u20$Output$u3d$R$GT$$u20$$u2b$$u20$$u27$a$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$::call_once::hc4b7698d3dffd34f (self=<error reading variable: access outside bounds of object referenced via synthetic pointer>, args=<optimized out>)
    at /builddir/build/BUILD/rustc-1.24.0-src/src/liballoc/boxed.rs:825
#19 0x00005555559b5438 in std::sys_common::thread::start_thread (main=0x7fffc4000cf0 "\000") at src/libstd/sys_common/thread.rs:24
#20 0x00005555559ab739 in std::sys::unix::thread::Thread::new::thread_start (main=0x2)
    at src/libstd/sys/unix/thread.rs:90
#21 0x00007ffff5913dd5 in start_thread (arg=0x7fffdd56b700) at pthread_create.c:308
---Type <return> to continue, or q <return> to quit---
#22 0x00007ffff5427b3d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 5 (Thread 0x7fffdf15c700 (LWP 1875)):
#0  0x00007ffff5421e59 in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007ffff5fc35de in g_cond_wait_until (cond=cond@entry=0x7fffe0003f18, mutex=mutex@entry=0x7fffe0003f10, end_time=end_time@entry=218773937628) at gthread-posix.c:1442
#2  0x00007ffff5f539b1 in g_async_queue_pop_intern_unlocked (queue=queue@entry=0x7fffe0003f10, wait=wait@entry=1, end_time=end_time@entry=218773937628) at gasyncqueue.c:422
#3  0x00007ffff5f53f6b in g_async_queue_timeout_pop (queue=0x7fffe0003f10, timeout=timeout@entry=15000000) at gasyncqueue.c:543
#4  0x00007ffff5fa635c in g_thread_pool_wait_for_new_pool () at gthreadpool.c:167
#5  0x00007ffff5fa635c in g_thread_pool_thread_proxy (data=<optimized out>)
    at gthreadpool.c:364
#6  0x00007ffff5fa5900 in g_thread_proxy (data=0x555556165320) at gthread.c:784
#7  0x00007ffff5913dd5 in start_thread (arg=0x7fffdf15c700) at pthread_create.c:308
#8  0x00007ffff5427b3d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 4 (Thread 0x7fffdffff700 (LWP 1873)):
#0  0x00007ffff541ce9d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff5f7ebdc in g_main_context_poll (priority=2147483647, n_fds=4, fds=0x7fffd4004310, timeout=-1, context=0x7fffe0016180) at gmain.c:4185
#2  0x00007ffff5f7ebdc in g_main_context_iterate (context=0x7fffe0016180, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3879
#3  0x00007ffff5f7ef2a in g_main_loop_run (loop=0x7fffe0017ef0) at gmain.c:4080
#4  0x00007ffff6f0e936 in gdbus_shared_thread_func (user_data=0x7fffe0017f50)
    at gdbusprivate.c:275
#5  0x00007ffff5fa5900 in g_thread_proxy (data=0x555555e70320) at gthread.c:784
#6  0x00007ffff5913dd5 in start_thread (arg=0x7fffdffff700) at pthread_create.c:308
#7  0x00007ffff5427b3d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 3 (Thread 0x7fffe4e61700 (LWP 1871)):
#0  0x00007ffff541ce9d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff5f7ebdc in g_main_context_poll (priority=2147483647, n_fds=2, fds=0x7fffd80008c0, timeout=-1, context=0x7fffe0004800) at gmain.c:4185
#2  0x00007ffff5f7ebdc in g_main_context_iterate (context=context@entry=0x7fffe0004800, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3879
#3  0x00007ffff5f7ed0c in g_main_context_iteration (context=0x7fffe0004800, may_block=may_block@entry=1) at gmain.c:3945
#4  0x00007ffff5f7ed49 in glib_worker_main (data=<optimized out>) at gmain.c:5740
#5  0x00007ffff5fa5900 in g_thread_proxy (data=0x555555e70280) at gthread.c:784
#6  0x00007ffff5913dd5 in start_thread (arg=0x7fffe4e61700) at pthread_create.c:308
#7  0x00007ffff5427b3d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 2 (Thread 0x7fffe5662700 (LWP 1870)):
#0  0x00007ffff541ce9d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff5f7ebdc in g_main_context_poll (priority=2147483647, n_fds=1, fds=0x7fffe00010e0, timeout=-1, context=0x555555e75a70) at gmain.c:4185
#2  0x00007ffff5f7ebdc in g_main_context_iterate (context=context@entry=0x555555e75a70, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3879
#3  0x00007ffff5f7ed0c in g_main_context_iteration (context=context@entry=0x555555e75a70, may_block=may_block@entry=1) at gmain.c:3945
---Type <return> to continue, or q <return> to quit---
#4  0x00007fffe566a53d in dconf_gdbus_worker_thread (user_data=0x555555e75a70)
    at dconf-gdbus-thread.c:82
#5  0x00007ffff5fa5900 in g_thread_proxy (data=0x555555e6dad0) at gthread.c:784
#6  0x00007ffff5913dd5 in start_thread (arg=0x7fffe5662700) at pthread_create.c:308
#7  0x00007ffff5427b3d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 1 (Thread 0x7ffff7fa5b80 (LWP 1806)):
#0  0x00007ffff541ce9d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff5f7ebdc in g_main_context_poll (priority=2147483647, n_fds=3, fds=0x555555ecfc40, timeout=15, context=0x555555e5fb40) at gmain.c:4185
#2  0x00007ffff5f7ebdc in g_main_context_iterate (context=context@entry=0x555555e5fb40, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3879
#3  0x00007ffff5f7ed0c in g_main_context_iteration (context=context@entry=0x555555e5fb40, may_block=may_block@entry=1) at gmain.c:3945
#4  0x00007ffff6ee2415 in g_application_run (application=0x7fffe0010790 [GtkApplication], argc=<optimized out>, argv=0x555555ecfc20) at gapplication.c:2401
#5  0x000055555576d442 in <O as gio::application::ApplicationExtManual>::run (self=0x7fffffffcf68, argv=...)
    at /home/matej/.cargo/registry/src/github.com-1ecc6299db9ec823/gio-0.3.0/src/application.rs:23
#6  0x000055555578a153 in nvim_gtk::main () at src/main.rs:96
(gdb) cont
Continuing.
[Thread 0x7fffdf15c700 (LWP 1875) exited]
ERROR 2018-03-10T00:45:41Z: neovim_lib::rpc::client: Error while reading: I/O error while reading marker byte: failed to fill whole buffer
[Thread 0x7fffdd36a700 (LWP 1885) exited]
[Thread 0x7fffdd56b700 (LWP 1883) exited]
[New Thread 0x7fffdf15c700 (LWP 5185)]
[Thread 0x7fffdf15c700 (LWP 5185) exited]
[Thread 0x7fffe4e61700 (LWP 1871) exited]
[Thread 0x7fffe5662700 (LWP 1870) exited]
[Thread 0x7ffff7fa5b80 (LWP 1806) exited]
[Inferior 1 (process 1806) exited normally]
(gdb) 
daa84 commented 6 years ago

Really hard to say. For me it just work. https://github.com/daa84/neovim-gtk/blob/3c743513e68c54ee489c69841f43740063c0b561/src/shell.rs#L187 - here open file code, it is simple. Just call e filename.

What version of neovim do you use? can you try different one?

mcepl commented 6 years ago

What version of neovim do you use? can you try different one?

Build by myself from the current master (commit 3c74351).

mcepl commented 6 years ago

Actually, not freeze completely. They are just completely ineffectual. If I click elsewhere to the window, the Gnome menu just vanishes and everything is fine (except of course, no file has been opened).

https://mcepl.fedorapeople.org/tmp/neovim-gtk-gnome-action.webm

mcepl commented 6 years ago

I tried this:

matej@mitmanek: neovim-gtk (master)$ rust-gdb target/debug/nvim-gtk
GNU gdb (GDB) Red Hat Enterprise Linux 8.0-17.1.scylladb.1.el7.centos
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from target/debug/nvim-gtk...done.
(gdb) b src/shell.rs:187
Breakpoint 1 at 0xd90b5: src/shell.rs:187. (2 locations)
(gdb) run
Starting program: /home/matej/archiv/knihovna/repos/neovim-gtk/target/debug/nvim-gtk 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffe5662700 (LWP 14115)]
[New Thread 0x7fffe4e61700 (LWP 14116)]
[New Thread 0x7fffdffff700 (LWP 14118)]
[New Thread 0x7fffdf15c700 (LWP 14168)]
[New Thread 0x7fffde95b700 (LWP 14169)]
[New Thread 0x7fffdd76c700 (LWP 14171)]
Detaching after fork from child process 14172.
[New Thread 0x7fffdd56b700 (LWP 14173)]
[New Thread 0x7fffdd36a700 (LWP 14174)]
[Thread 0x7fffdd76c700 (LWP 14171) exited]
[Thread 0x7fffde95b700 (LWP 14169) exited]

Thread 1 "nvim-gtk" hit Breakpoint 1, nvim_gtk::shell::State::open_file (
    self=0x555555f2e3c0, 
    path="/home/matej/archiv/2016/clanky/petunia_dursley/08_kobylky.rst")
    at src/shell.rs:187
187             nvim.command(&format!("e {}", path)).report_err();
(gdb) p path
$1 = "/home/matej/archiv/2016/clanky/petunia_dursley/08_kobylky.rst"
(gdb) step
<nvim_gtk::nvim::client::NeovimRef<'a> as core::ops::deref::DerefMut>::deref_mut (
    self=0x7fffffffb3a0) at src/nvim/client.rs:61
61          match *self {
(gdb) n
62              NeovimRef::SingleThreaded(ref mut nvim) => &mut *nvim,
(gdb) 
61          match *self {
(gdb) 
65      }
(gdb) 

Thread 1 "nvim-gtk" hit Breakpoint 1, nvim_gtk::shell::State::open_file (
    self=0x555555f2e3c0, 
    path="/home/matej/archiv/2016/clanky/petunia_dursley/08_kobylky.rst")
    at src/shell.rs:187
187             nvim.command(&format!("e {}", path)).report_err();
(gdb) 
ERROR 2018-03-12T10:45:04Z: nvim_gtk::nvim::ext: Unknown error type: Wait timeout (nvim_command)
186         if let Some(mut nvim) = self.nvim() {
(gdb) 

Any better place to put breakpoint to?

mcepl commented 6 years ago

Actually, it is more silly. That action in the last files dialog requires double-click, whereas my gedit reacts just to single-click. I was confused by some logging messages I have had in my ~/.vim/vimrc, but when I remove them, everything works except for this weirdness.

daa84 commented 6 years ago

looks like #64 patch need to be adapted :smile: