canonical / mir

The Mir compositor
GNU General Public License v2.0
637 stars 102 forks source link

eglstream-kms: deadlock on (only?) display dis/connection #3273

Open Saviq opened 8 months ago

Saviq commented 8 months ago

RAOF: Yeah. Maybe we're racing something and page flipping is hanging which then hangs the compositor threads, which then causes the display reconfiguration to hang when it tries to stop the compositor...? RAOF: Having typed that out, it seems pretty plausible :0

With #3272 I can confirm we're receiving the UDEV events:

< - debug - > gbm-kms: Handling UDEV events
< - debug - > gbm-kms: Processing UDEV event for /devices/pci0000:00/0000:00:02.0/drm/card0: 2

On connection there's another message printed:

< -warning- > gbm-kms: Unable to determine the current display mode.

Following that, we're in a deadlock in both cases. GDB says: disconnection.txt (startup connected, then disconnect) connection.txt (startup disconnected, then connect)

Saviq commented 8 months ago

Top of stack:

Thread 1 (Thread 0x7fd642e06700 (LWP 11026) "mir_demo_server"):
#0  futex_wait (private=0, expected=2, futex_word=0x5577c28271f0) at ../sysdeps/nptl/futex-internal.h:146
#1  __GI___lll_lock_wait (futex=futex@entry=0x5577c28271f0, private=0) at ./nptl/lowlevellock.c:49
#2  0x00007fd643a98002 in lll_mutex_lock_optimized (mutex=0x5577c28271f0) at ./nptl/pthread_mutex_lock.c:48
#3  ___pthread_mutex_lock (mutex=0x5577c28271f0) at ./nptl/pthread_mutex_lock.c:93
#4  0x00007fd641d64e1a in __gthread_mutex_lock(__gthread_mutex_t*) (__mutex=0x5577c28271f0) at /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:749
#5  0x00007fd641d64ec0 in std::mutex::lock() (this=0x5577c28271f0) at /usr/include/c++/11/bits/std_mutex.h:100
#6  0x00007fd641d657ba in std::lock_guard<std::mutex>::lock_guard(std::mutex&) (this=0x7ffc676f8980, __m=...) at /usr/include/c++/11/bits/std_mutex.h:229
#7  0x00007fd641d6de77 in mir::graphics::eglstream::Display::configuration() const (this=0x5577c28271c0) at /home/ubuntu/mir/src/platforms/eglstream-kms/server/display.cpp:498
#8  0x00007fd6444a2fcc in mir::graphics::MultiplexingDisplay::configuration() const (this=0x5577c24f69e0) at /home/ubuntu/mir/src/server/graphics/multiplexing_display.cpp:248
#9  0x00007fd64429d010 in mir::DisplayServer::Private::configure_display() (this=0x5577c22ad250) at /home/ubuntu/mir/src/server/display_server.cpp:191
#10 0x00007fd64429bfad in mir::DisplayServer::Private::Private(mir::ServerConfiguration&)::{lambda()#1}::operator()() const (__closure=0x5577c2e58800) at /home/ubuntu/mir/src/server/display_server.cpp:91
#11 0x00007fd6442a010a in std::__invoke_impl<void, mir::DisplayServer::Private::Private(mir::ServerConfiguration&)::{lambda()#1}&>(std::__invoke_other, mir::DisplayServer::Private::Private(mir::ServerConfiguration&)::{lambda()#1}&) (__f=...) at /usr/include/c++/11/bits/invoke.h:61
#12 0x00007fd64429f637 in std::__invoke_r<void, mir::DisplayServer::Private::Private(mir::ServerConfiguration&)::{lambda()#1}&>(mir::DisplayServer::Private::Private(mir::ServerConfiguration&)::{lambda()#1}&) (__fn=...) at /usr/include/c++/11/bits/invoke.h:111
#13 0x00007fd64429e712 in std::_Function_handler<void (), mir::DisplayServer::Private::Private(mir::ServerConfiguration&)::{lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...) at /usr/include/c++/11/bits/std_function.h:290
#14 0x00007fd641d66096 in std::function<void ()>::operator()() const (this=0x5577c2e58800) at /usr/include/c++/11/bits/std_function.h:590
#15 0x00007fd641d6e316 in operator()(mir::udev::Monitor::EventType, mir::udev::Device const&) const (__closure=0x5577c2e58800) at /home/ubuntu/mir/src/platforms/eglstream-kms/server/display.cpp:552
#16 0x00007fd641d6fe78 in std::__invoke_impl<void, mir::graphics::eglstream::Display::register_configuration_change_handler(mir::graphics::EventHandlerRegister&, const DisplayConfigurationChangeHandler&)::<lambda(int)>::<lambda(mir::udev::Monitor::EventType, const mir::udev::Device&)>&, mir::udev::Monitor::EventType, const mir::udev::Device&>(std::__invoke_other, struct {...} &) (__f=...) at /usr/include/c++/11/bits/invoke.h:61
#17 0x00007fd641d6f9e1 in std::__invoke_r<void, mir::graphics::eglstream::Display::register_configuration_change_handler(mir::graphics::EventHandlerRegister&, const DisplayConfigurationChangeHandler&)::<lambda(int)>::<lambda(mir::udev::Monitor::EventType, const mir::udev::Device&)>&, mir::udev::Monitor::EventType, const mir::udev::Device&>(struct {...} &) (__fn=...) at /usr/include/c++/11/bits/invoke.h:111
#18 0x00007fd641d6f38d in std::_Function_handler<void(mir::udev::Monitor::EventType, const mir::udev::Device&), mir::graphics::eglstream::Display::register_configuration_change_handler(mir::graphics::EventHandlerRegister&, const DisplayConfigurationChangeHandler&)::<lambda(int)>::<lambda(mir::udev::Monitor::EventType, const mir::udev::Device&)> >::_M_invoke(const std::_Any_data &, mir::udev::Monitor::EventType &&, const mir::udev::Device &) (__functor=..., __args#0=@0x7ffc676f8c54: mir::udev::Monitor::CHANGED, __args#1=...) at /usr/include/c++/11/bits/std_function.h:290
#19 0x00007fd64417dcd0 in std::function<void (mir::udev::Monitor::EventType, mir::udev::Device const&)>::operator()(mir::udev::Monitor::EventType, mir::udev::Device const&) const (this=0x7ffc676f8cf0, __args#0=mir::udev::Monitor::CHANGED, __args#1=...) at /usr/include/c++/11/bits/std_function.h:590
#20 0x00007fd64417d0a5 in mir::udev::Monitor::process_events(std::function<void (mir::udev::Monitor::EventType, mir::udev::Device const&)> const&) const (this=0x5577c32cfa80, handler=...) at /home/ubuntu/mir/src/platform/udev/udev_wrapper.cpp:355
#21 0x00007fd641d6e3ed in operator()(int) const (__closure=0x5577c2e79930) at /home/ubuntu/mir/src/platforms/eglstream-kms/server/display.cpp:547
#22 0x00007fd641d703a6 in std::__invoke_impl<void, mir::graphics::eglstream::Display::register_configuration_change_handler(mir::graphics::EventHandlerRegister&, const DisplayConfigurationChangeHandler&)::<lambda(int)>&, int>(std::__invoke_other, struct {...} &) (__f=...) at /usr/include/c++/11/bits/invoke.h:61
#23 0x00007fd641d70008 in std::__invoke_r<void, mir::graphics::eglstream::Display::register_configuration_change_handler(mir::graphics::EventHandlerRegister&, const DisplayConfigurationChangeHandler&)::<lambda(int)>&, int>(struct {...} &) (__fn=...) at /usr/include/c++/11/bits/invoke.h:111
#24 0x00007fd641d6fb27 in std::_Function_handler<void(int), mir::graphics::eglstream::Display::register_configuration_change_handler(mir::graphics::EventHandlerRegister&, const DisplayConfigurationChangeHandler&)::<lambda(int)> >::_M_invoke(const std::_Any_data &, int &&) (__functor=..., __args#0=@0x7ffc676f8df4: 57) at /usr/include/c++/11/bits/std_function.h:290

And can confirm that limiting ourselves to the mir:gbm-kms platform makes this go away.