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

SIGSEGV on Monitor Disconnect/Connect #554

Closed
jameswalmsley opened this issue Jan 13, 2020 · 9 comments · Fixed by #555
Closed

SIGSEGV on Monitor Disconnect/Connect #554

jameswalmsley opened this issue Jan 13, 2020 · 9 comments · Fixed by #555

Comments

@jameswalmsley
Copy link

#0  0x00005555555f2c7a in Glib::RefPtr<Gdk::Monitor>::operator==(Glib::RefPtr<Gdk::Monitor> const&) const (this=0x0, src=...) at /usr/include/glibmm-2.4/glibmm/refptr.h:394
#1  0x00005555555e9bc5 in waybar::Client::<lambda(const auto:2&)>::operator()<std::unique_ptr<waybar::waybar_output> >(const std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> > &) const
    (__closure=0x7fffffffc678, output=std::unique_ptr<waybar::waybar_output> = {...}) at ../src/client.cpp:155
#2  0x00005555555e9bf8 in __gnu_cxx::__ops::_Iter_pred<waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor>)::<lambda(const auto:2&)> >::operator()<__gnu_cxx::__normal_iterator<std::unique_ptr<waybar::waybar_output>*, std::vector<std::unique_ptr<waybar::waybar_output> > > >(__gnu_cxx::__normal_iterator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >*, std::vector<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >, std::allocator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> > > > >) (this=0x7fffffffc678, __it=std::unique_ptr<waybar::waybar_output> = {get() = 0x0})
    at /usr/include/c++/9/bits/predefined_ops.h:283
#3  0x00005555555e98d5 in std::__remove_if<__gnu_cxx::__normal_iterator<std::unique_ptr<waybar::waybar_output>*, std::vector<std::unique_ptr<waybar::waybar_output> > >, __gnu_cxx::__ops::_Iter_pred<waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor>)::<lambda(const auto:2&)> > >(__gnu_cxx::__normal_iterator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >*, std::vector<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >, std::allocator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> > > > >, __gnu_cxx::__normal_iterator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >*, std::vector<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >, std::allocator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> > > > >, __gnu_cxx::__ops::_Iter_pred<waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor>)::<lambda(const auto:2&)> >) (__first=std::unique_ptr<waybar::waybar_output> = {get() = 0x0}, __last=
  std::unique_ptr<waybar::waybar_output> = {get() = 0x55550000000a}, __pred=...) at /usr/include/c++/9/bits/stl_algo.h:869
#4  0x00005555555e9753 in std::remove_if<__gnu_cxx::__normal_iterator<std::unique_ptr<waybar::waybar_output>*, std::vector<std::unique_ptr<waybar::waybar_output> > >, waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor>)::<lambda(const auto:2&)> >(__gnu_cxx::__normal_iterator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >*, std::vector<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >, std::allocator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> > > > >, __gnu_cxx::__normal_iterator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >*, std::vector<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> >, std::allocator<std::unique_ptr<waybar::waybar_output, std::default_delete<waybar::waybar_output> > > > >, waybar::Client::<lambda(const auto:2&)>) (__first=std::unique_ptr<waybar::waybar_output> = {get() = 0x555555961d00}, __last=std::unique_ptr<waybar::waybar_output> = {get() = 0x55550000000a}, __pred=...) at /usr/include/c++/9/bits/stl_algo.h:939
#5  0x00005555555e72a5 in waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor>) (this=0x555555725790, monitor=...) at ../src/client.cpp:156
#6  0x000055555560093e in sigc::bound_mem_functor1<void, waybar::Client, Glib::RefPtr<Gdk::Monitor> >::operator()(Glib::RefPtr<Gdk::Monitor> const&) const (this=0x555555748b98, _A_a1=...)
    at /usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:2066
#7  0x00005555555fede5 in sigc::adaptor_functor<sigc::bound_mem_functor1<void, waybar::Client, Glib::RefPtr<Gdk::Monitor> > >::operator()<Glib::RefPtr<Gdk::Monitor> const&>(Glib::RefPtr<Gdk::Monitor> const&) const
    (this=0x555555748b90, _A_arg1=...) at /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:89
#8  0x00005555555fce61 in sigc::internal::slot_call1<sigc::bound_mem_functor1<void, waybar::Client, Glib::RefPtr<Gdk::Monitor> >, void, Glib::RefPtr<Gdk::Monitor> const&>::call_it(sigc::internal::slot_rep*, Glib::RefPtr<Gdk::Monitor> const&) (rep=0x555555748b60, a_1=...) at /usr/include/sigc++-2.0/sigc++/functors/slot.h:170
#9  0x00007ffff779c1c4 in  () at /lib/x86_64-linux-gnu/libgdkmm-3.0.so.1
#10 0x00007ffff6aecde3 in g_cclosure_marshal_VOID__OBJECTv () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007ffff6ae9936 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x00007ffff6b0636c in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#13 0x00007ffff6b069b3 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#14 0x00007ffff6d47dda in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#15 0x00007ffff6dad9d3 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#16 0x00007ffff6da5ac4 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#17 0x00007ffff635c81e in ffi_call_unix64 () at /lib/x86_64-linux-gnu/libffi.so.6
#18 0x00007ffff635c1ef in ffi_call () at /lib/x86_64-linux-gnu/libffi.so.6
#19 0x00007ffff7fc2668 in wl_closure_invoke (closure=closure@entry=0x555555895c00, flags=flags@entry=1, target=<optimised out>, target@entry=0x5555557edae0, opcode=opcode@entry=1, data=<optimised out>)
    at /home/james/develop/ve-root/sources/sway/L_wayland/wayland/src/connection.c:1018
#20 0x00007ffff7fbef08 in dispatch_event (display=display@entry=0x5555557b4730, queue=<optimised out>) at /home/james/develop/ve-root/sources/sway/L_wayland/wayland/src/wayland-client.c:1445
#21 0x00007ffff7fc04dc in dispatch_queue (queue=0x5555557b4800, display=0x5555557b4730) at /home/james/develop/ve-root/sources/sway/L_wayland/wayland/src/wayland-client.c:1591
#22 0x00007ffff7fc04dc in wl_display_dispatch_queue_pending (display=0x5555557b4730, queue=0x5555557b4800) at /home/james/develop/ve-root/sources/sway/L_wayland/wayland/src/wayland-client.c:1833
#23 0x00007ffff6da8738 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#24 0x00007ffff6d45094 in gdk_display_get_event () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#25 0x00007ffff6da8436 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#26 0x00007ffff69fe84d in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#27 0x00007ffff69fead0 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#28 0x00007ffff69feb73 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#29 0x00007ffff6c11b05 in g_application_run () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#30 0x00005555555e907e in waybar::Client::main(int, char**) (this=0x555555725790, argc=1, argv=0x7fffffffdb18) at ../src/client.cpp:270
#31 0x00005555555d987e in main(int, char**) (argc=1, argv=0x7fffffffdb18) at ../src/main.cpp:22

Will try to look into the code and debug a little to see whats going on.

J

alebastr added a commit to alebastr/Waybar that referenced this issue Jan 14, 2020
…tput>.

Should fix Alexays#554, where unique_ptr was moved out from the outputs_ vector.
@alebastr
Copy link
Contributor

Ouch. Something caused first element of outputs_ to be moved out, leaving empty unique_ptr behind.
#3 <omitted...> (__first=std::unique_ptr<waybar::waybar_output> = {get() = 0x0}, __last=std::unique_ptr<waybar::waybar_output> = {get() = 0x55550000000a}, __pred=...)

I had a hunch that using unique_ptr for outputs is not necessary but did not follow up with that. alebastr@718fc42 should fix the crash, but I won't be able to test until tomorrow.

@jameswalmsley
Copy link
Author

@alebastr I'll apply and test your patch today. Many thanks for the quick response. I was going to hunt this one down myself. But haven't got to grips with the code base yet.

@jameswalmsley
Copy link
Author

@alebastr this works in that it resolves the crash when I unplug and plugin my monitors.

However the bar only appears on a single output.

alebastr added a commit to alebastr/Waybar that referenced this issue Jan 14, 2020
std::unique_ptr is not required here as the only benefit it gives is
stability of address on vector resize and it's easy to invalidate it
accidentaly. std::list provides the same guarantee of stable addresses
of the elements and correct destruction while avoiding smart pointer
overhead.

Also fixes Alexays#554, caused by incorrect usage of std::remove_if.
@alebastr
Copy link
Contributor

@jameswalmsley please test #555.
I kind of forgot that std::vector invalidates references on resize, thus my previous patch is not supposed to be working. If anything, it should be crashing more often.

@jameswalmsley
Copy link
Author

Hi @alebastr,

I can confirm this works. I'll test it full time on my machine for the rest of the week.

Seems great so far.

Best

J

@josteink
Copy link
Contributor

josteink commented May 16, 2020

I can confirm this issue is fixed, but a new, similar issue has arisen instead: When I disconnect my docking (and thus the monitors, two), Waybar seems to lock up and become iresponsive (but not quit or disappear). Clock wont update, clicking volume wont open pavucontrol, etc.

Disconnecting the dock should not cause a network-change, because the dock has no ethernet connected, and the laptop is on wifi only.

Connecting dock causes no issues, so the issue seem isolated to removal of displays.

I've done a local build from git master, launched waybar with gdb, and have the following backtrace when waybar has reached this conditon:

Thread 1 "waybar" received signal SIGINT, Interrupt.
__pthread_clockjoin_ex (threadid=140736666261248, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145
145	pthread_join_common.c: No such file or directory.
(gdb) bt
#0  __pthread_clockjoin_ex (threadid=140736666261248, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145
#1  0x00007ffff6839f17 in std::thread::join() () at /lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00005555555e91a0 in waybar::modules::Network::~Network() ()
#3  0x00005555555e920d in waybar::modules::Network::~Network() ()
#4  0x00005555555c8b21 in waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor>) ()
#5  0x00005555555c9805 in sigc::internal::slot_call1<sigc::bound_mem_functor1<void, waybar::Client, Glib::RefPtr<Gdk::Monitor> >, void, Glib::RefPtr<Gdk::Monitor> const&>::call_it(sigc::internal::slot_rep*, Glib::RefPtr<Gdk::Monitor> const&) ()
#6  0x00007ffff78ed1c4 in  () at /lib/x86_64-linux-gnu/libgdkmm-3.0.so.1
#7  0x00007ffff6b6af03 in g_cclosure_marshal_VOID__OBJECTv () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x00007ffff6b67a56 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x00007ffff6b86b28 in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#10 0x00007ffff6b870d3 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007ffff6dcee3a in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#12 0x00007ffff6e34ec3 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#13 0x00007ffff6e2cfb4 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#14 0x00007ffff63dcff5 in  () at /lib/x86_64-linux-gnu/libffi.so.7
#15 0x00007ffff63dc40a in  () at /lib/x86_64-linux-gnu/libffi.so.7
#16 0x00007ffff7fa83a8 in  () at /lib/x86_64-linux-gnu/libwayland-client.so.0
#17 0x00007ffff7fa4c48 in  () at /lib/x86_64-linux-gnu/libwayland-client.so.0
#18 0x00007ffff7fa621c in wl_display_dispatch_queue_pending () at /lib/x86_64-linux-gnu/libwayland-client.so.0
#19 0x00007ffff6e2fc28 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#20 0x00007ffff6dcc0f4 in gdk_display_get_event () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#21 0x00007ffff6e2f926 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#22 0x00007ffff6a79fbd in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#23 0x00007ffff6a7a240 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#24 0x00007ffff6a7a2e3 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007ffff6c95fd5 in g_application_run () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#26 0x000055555558787c in waybar::Client::main(int, char**) ()
#27 0x0000555555586a34 in main ()
(gdb) 

Anyone else experiencing this? Running on Ubuntu 20.04, if that matters.

@Alexays
Copy link
Owner

Alexays commented May 16, 2020

I can confirm this issue is fixed, but a new, similar issue has arisen instead: When I disconnect my docking (and thus the monitors, two), Waybar seems to lock up and become iresponsive (but not quit or disappear). Clock wont update, clicking volume wont open pavucontrol, etc.

Disconnecting the dock should not cause a network-change, because the dock has no ethernet connected, and the laptop is on wifi only.

Connecting dock causes no issues, so the issue seem isolated to removal of displays.

I've done a local build from git master, launched waybar with gdb, and have the following backtrace when waybar has reached this conditon:

Thread 1 "waybar" received signal SIGINT, Interrupt.
__pthread_clockjoin_ex (threadid=140736666261248, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145
145	pthread_join_common.c: No such file or directory.
(gdb) bt
#0  __pthread_clockjoin_ex (threadid=140736666261248, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145
#1  0x00007ffff6839f17 in std::thread::join() () at /lib/x86_64-linux-gnu/libstdc++.so.6
#2  0x00005555555e91a0 in waybar::modules::Network::~Network() ()
#3  0x00005555555e920d in waybar::modules::Network::~Network() ()
#4  0x00005555555c8b21 in waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor>) ()
#5  0x00005555555c9805 in sigc::internal::slot_call1<sigc::bound_mem_functor1<void, waybar::Client, Glib::RefPtr<Gdk::Monitor> >, void, Glib::RefPtr<Gdk::Monitor> const&>::call_it(sigc::internal::slot_rep*, Glib::RefPtr<Gdk::Monitor> const&) ()
#6  0x00007ffff78ed1c4 in  () at /lib/x86_64-linux-gnu/libgdkmm-3.0.so.1
#7  0x00007ffff6b6af03 in g_cclosure_marshal_VOID__OBJECTv () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x00007ffff6b67a56 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x00007ffff6b86b28 in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#10 0x00007ffff6b870d3 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007ffff6dcee3a in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#12 0x00007ffff6e34ec3 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#13 0x00007ffff6e2cfb4 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#14 0x00007ffff63dcff5 in  () at /lib/x86_64-linux-gnu/libffi.so.7
#15 0x00007ffff63dc40a in  () at /lib/x86_64-linux-gnu/libffi.so.7
#16 0x00007ffff7fa83a8 in  () at /lib/x86_64-linux-gnu/libwayland-client.so.0
#17 0x00007ffff7fa4c48 in  () at /lib/x86_64-linux-gnu/libwayland-client.so.0
#18 0x00007ffff7fa621c in wl_display_dispatch_queue_pending () at /lib/x86_64-linux-gnu/libwayland-client.so.0
#19 0x00007ffff6e2fc28 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#20 0x00007ffff6dcc0f4 in gdk_display_get_event () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#21 0x00007ffff6e2f926 in  () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#22 0x00007ffff6a79fbd in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#23 0x00007ffff6a7a240 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#24 0x00007ffff6a7a2e3 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007ffff6c95fd5 in g_application_run () at /lib/x86_64-linux-gnu/libgio-2.0.so.0
#26 0x000055555558787c in waybar::Client::main(int, char**) ()
#27 0x0000555555586a34 in main ()
(gdb) 

Anyone else experiencing this? Running on Ubuntu 20.04, if that matters.

I'll take a look to this one. thx for reporting.

@josteink
Copy link
Contributor

Another finding I've just had is that when I connect the dock (and thus my 2 external monitors), waybar does not freeze or crash. But it doesn't show up on those monitors either, until I kill it and restart it.

Should I register that as a bug of its own?

@josteink
Copy link
Contributor

josteink commented Jun 8, 2020

Just wanted to let you know that I've pulled latest sources and rebuilt, and Waybar now seems to handle disconnect and reconnects cleanly.

No breaks in GDB, no errors in the log, just the events you would expect, and most importantly: things just works(tm), both connects and disconnects.

Whatever you did, it seems to have worked. Thanks! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants