Bug 499847 - Assert in QWindow::setCursor on connect
Summary: Assert in QWindow::setCursor on connect
Status: RESOLVED FIXED
Alias: None
Product: krdc
Classification: Applications
Component: RDP (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Urs Wolfer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-02-12 01:10 UTC by Nicolas Fella
Modified: 2025-02-12 14:01 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Fella 2025-02-12 01:10:47 UTC
SUMMARY
When connecting to a RDP host I get the following crash

ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread QThread(0x5020001295b0). Receiver 'QWidgetWindow(0x5080000c89a0, name = "MainWindow#1Window")' was created in thread QThread(0x5020000014d0, name = "Qt mainThread")", file /home/nico/workspace/qt6-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp, line 526


#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007fffed49a1c3 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
#2  0x00007fffed441436 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007fffed42891a in __GI_abort () at abort.c:79
#4  0x00007fffeddab7c2 in qAbort () at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qassert.cpp:46
#5  0x00007fffede04611 in qt_message_fatal<QString&> (context=..., message=...) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:2062
#6  0x00007fffede05e4b in qt_message(QtMsgType, const QMessageLogContext &, const char *, typedef __va_list_tag __va_list_tag *)
    (msgType=msgType@entry=QtFatalMsg, context=..., msg=msg@entry=0x7fffee903d60 "ASSERT failure in %s: \"%s\", file %s, line %d", ap=ap@entry=0x7fffa77b1c20) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:342
#7  0x00007fffede1442f in QMessageLogger::fatal (this=this@entry=0x7fffa75ba8a0, msg=msg@entry=0x7fffee903d60 "ASSERT failure in %s: \"%s\", file %s, line %d") at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qlogging.cpp:831
#8  0x00007fffeddabaa1 in qt_assert_x
    (where=where@entry=0x7fffee93e740 "QCoreApplication::sendEvent", what=what@entry=0x51700006c190 "Cannot send events to objects owned by a different thread. Current thread QThread(0x5020001295b0). Receiver 'QWidgetWindow(0x5080000c89a0, name = \"MainWindow#1Window\")' was created in thread QThread(0"..., file=file@entry=0x7fffee93c500 "/home/nico/workspace/qt6-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp", line=line@entry=526) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/global/qassert.cpp:115
#9  0x00007fffedfa6cb3 in QCoreApplicationPrivate::checkReceiverThread (receiver=receiver@entry=0x5080000c89a0) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:526
#10 0x00007ffff1488ab6 in QApplication::notify (this=0x7fffe5000220, receiver=<optimized out>, e=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/widgets/kernel/qapplication.cpp:2590
#11 0x00007fffedfa9294 in QCoreApplication::notifyInternal2 (receiver=0x5080000c89a0, event=event@entry=0x7fffa75b51e0) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1098
#12 0x00007fffedfa9485 in QCoreApplication::sendEvent (receiver=receiver@entry=0x5080000c89a0, event=event@entry=0x7fffa75b51e0) at /home/nico/workspace/qt6-dev/qtbase/src/corelib/kernel/qcoreapplication.cpp:1538
#13 0x00007fffef7bff0a in QWindowPrivate::setCursor (this=<optimized out>, newCursor=newCursor@entry=0x7fffa74ae9e0) at /home/nico/workspace/qt6-dev/qtbase/src/gui/kernel/qwindow.cpp:3249
#14 0x00007fffef7bff6d in QWindow::setCursor (this=<optimized out>, cursor=...) at /home/nico/workspace/qt6-dev/qtbase/src/gui/kernel/qwindow.cpp:3207
#15 0x00007ffff1570f47 in applyCursor (w=w@entry=0x511000111ec0, c=...) at /home/nico/workspace/qt6-dev/qtbase/src/widgets/kernel/qwidget.cpp:5020
#16 0x00007ffff1592fd9 in qt_qpa_set_cursor (w=0x512000145cc0, force=force@entry=false) at /home/nico/workspace/qt6-dev/qtbase/src/widgets/kernel/qwidget.cpp:5058
#17 0x00007ffff159309c in QWidgetPrivate::setCursor_sys (this=this@entry=0x5160006b3a80, cursor=...) at /home/nico/workspace/qt6-dev/qtbase/src/widgets/kernel/qwidget.cpp:4995
#18 0x00007ffff15aae2b in QWidget::setCursor (this=0x512000145cc0, cursor=<optimized out>) at /home/nico/workspace/qt6-dev/qtbase/src/widgets/kernel/qwidget.cpp:4985
#19 0x00007fffc9ff9211 in RdpView::setRemoteCursor (this=0x512000145cc0, cursor=...) at /home/nico/kde-qtdev/src/krdc/rdp/rdpview.cpp:403
#20 0x00007fffc9fbf1a6 in RdpGraphics::onPointerSet (context=0x51f00015b680, pointer=0x50f00009d750) at /home/nico/kde-qtdev/src/krdc/rdp/rdpgraphics.cpp:76
#21 0x00007fffc9b14ab0 in fastpath_recv_update (fastpath=<optimized out>, updateCode=<optimized out>, s=0x506000375fe0) at ./libfreerdp/core/fastpath.c:460
#22 0x00007fffc9b0266a in fastpath_recv_update_data (fastpath=0x5040001fc110, s=0x506000140660) at ./libfreerdp/core/fastpath.c:560
#23 fastpath_recv_updates (fastpath=0x5040001fc110, s=0x506000140660) at ./libfreerdp/core/fastpath.c:646
#24 rdp_recv_fastpath_pdu (rdp=<optimized out>, s=0x506000140660) at ./libfreerdp/core/rdp.c:1776
#25 0x00007fffc9b05b11 in rdp_recv_pdu (rdp=<optimized out>, s=0x506000140660) at ./libfreerdp/core/rdp.c:1785
#26 rdp_recv_callback_int (transport=0x5170000cc580, s=0x506000140660, extra=<optimized out>) at ./libfreerdp/core/rdp.c:2112
#27 rdp_recv_callback (transport=0x5170000cc580, s=0x506000140660, extra=0x5160004b3f80) at ./libfreerdp/core/rdp.c:2157
#28 0x00007fffc9b0b2e6 in transport_check_fds (transport=0x5170000cc580) at ./libfreerdp/core/transport.c:1466
#29 rdp_check_fds (rdp=0x5160004b3f80) at ./libfreerdp/core/rdp.c:2221
#30 0x00007fffc9ad4a04 in freerdp_check_fds (instance=0x5160004b4880) at ./libfreerdp/core/freerdp.c:352
#31 0x00007fffc9ad8351 in freerdp_check_event_handles (context=0x51f00015b680) at ./libfreerdp/core/freerdp.c:441
#32 0x00007fffca009a04 in RdpSession::run (this=0x51100035a240) at /home/nico/kde-qtdev/src/krdc/rdp/rdpsession.cpp:1116
#33 0x00007fffca00eee9 in std::__invoke_impl<void, void (RdpSession::*&)(), RdpSession*&> (__f=@0x5030005d7c98: (void (RdpSession::*)(class RdpSession * const)) 0x7fffca0095f8 <RdpSession::run()>, __t=@0x5030005d7ca8: 0x51100035a240)
    at /usr/include/c++/14/bits/invoke.h:74
#34 0x00007fffca00eddf in std::__invoke<void (RdpSession::*&)(), RdpSession*&> (__fn=@0x5030005d7c98: (void (RdpSession::*)(class RdpSession * const)) 0x7fffca0095f8 <RdpSession::run()>) at /usr/include/c++/14/bits/invoke.h:96
#35 0x00007fffca00ed2b in std::_Bind<void (RdpSession::*(RdpSession*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) (this=0x5030005d7c98, __args=...) at /usr/include/c++/14/functional:513
#36 0x00007fffca00ec25 in std::_Bind<void (RdpSession::*(RdpSession*))()>::operator()<, void>() (this=0x5030005d7c98) at /usr/include/c++/14/functional:598
#37 0x00007fffca00eb74 in std::__invoke_impl<void, std::_Bind<void (RdpSession::*(RdpSession*))()>>(std::__invoke_other, std::_Bind<void (RdpSession::*(RdpSession*))()>&&) (__f=...) at /usr/include/c++/14/bits/invoke.h:61
#38 0x00007fffca00eb37 in std::__invoke<std::_Bind<void (RdpSession::*(RdpSession*))()>>(std::_Bind<void (RdpSession::*(RdpSession*))()>&&) (__fn=...) at /usr/include/c++/14/bits/invoke.h:96
#39 0x00007fffca00eae4 in std::thread::_Invoker<std::tuple<std::_Bind<void (RdpSession::*(RdpSession*))()> > >::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x5030005d7c98) at /usr/include/c++/14/bits/std_thread.h:301
#40 0x00007fffca00eab8 in std::thread::_Invoker<std::tuple<std::_Bind<void (RdpSession::*(RdpSession*))()> > >::operator()() (this=0x5030005d7c98) at /usr/include/c++/14/bits/std_thread.h:308
#41 0x00007fffca00ea9c in std::thread::_State_impl<std::thread::_Invoker<std::tuple<std::_Bind<void (RdpSession::*(RdpSession*))()> > > >::_M_run() (this=0x5030005d7c90) at /usr/include/c++/14/bits/std_thread.h:253
#42 0x00007fffed8ed3e4 in std::execute_native_thread_routine (__p=__p@entry=0x5030005d7c90) at ../../../../../libstdc++-v3/src/c++11/thread.cc:104
#43 0x00007ffff7862cd6 in asan_thread_start (arg=0x7fffe1828000) at ../../../../libsanitizer/asan/asan_interceptors.cpp:234
#44 0x00007fffed498292 in start_thread (arg=<optimized out>) at pthread_create.c:447
#45 0x00007fffed51d4fc in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

SOFTWARE/OS VERSIONS
KDE Plasma Version: master
KDE Frameworks Version: master
Qt Version: dev

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2025-02-12 13:17:58 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/krdc/-/merge_requests/168
Comment 2 Fabio 2025-02-12 13:20:22 UTC
Can you please check if https://invent.kde.org/network/krdc/-/merge_requests/168 fixed the issue for you? 
I can't get that assert to trigger on Qt 6.8.2 :(
While you're on it, can you please check if copy/pasting from the remote host to local causes a similar crash? https://invent.kde.org/network/krdc/-/blob/master/rdp/rdpcliprdr.cpp?ref_type=heads#L284 seems suspiciously similar
Comment 3 Nicolas Fella 2025-02-12 13:53:05 UTC
> While you're on it, can you please check if copy/pasting from the remote host to local causes a similar crash? https://invent.kde.org/network/krdc/-/blob/master/rdp/rdpcliprdr.cpp?ref_type=heads#L284 seems suspiciously similar

Do I need to do something particular for this? Merely copying some text on the remote system doesn't seem to crash. I don't see the text in the host clipboard though
Comment 4 Nicolas Fella 2025-02-12 13:54:19 UTC
When I connect to a Gnome VM via RDP I (sometimes) don't get a visible cursor at all. But perhaps that is an unrelated issue
Comment 5 Fabio 2025-02-12 13:56:47 UTC
Git commit 546b408738b2fd336c7297de247cc58701a8f09d by Fabio Bas.
Committed on 12/02/2025 at 13:53.
Pushed by ctrlaltca into branch 'master'.

Rdp: use signal/slot for setRemoteCursor to avoid cross-thread method call

M  +5    -13   rdp/rdpgraphics.cpp
M  +5    -0    rdp/rdpsession.cpp
M  +3    -0    rdp/rdpsession.h
M  +3    -1    rdp/rdpview.cpp
M  +1    -1    rdp/rdpview.h

https://invent.kde.org/network/krdc/-/commit/546b408738b2fd336c7297de247cc58701a8f09d
Comment 6 Fabio 2025-02-12 13:58:36 UTC
(In reply to Nicolas Fella from comment #3)
> Do I need to do something particular for this? Merely copying some text on
> the remote system doesn't seem to crash. I don't see the text in the host
> clipboard though

Not really, if the remote host supports clipboard sharing it should work automatically.
If you were trying Krdp it doesn't support clipboard yet. I usually test on a windows vm
Comment 7 Fabio 2025-02-12 14:01:43 UTC
(In reply to Nicolas Fella from comment #4)
> When I connect to a Gnome VM via RDP I (sometimes) don't get a visible
> cursor at all. But perhaps that is an unrelated issue

We have this bug for VNC: https://bugs.kde.org/show_bug.cgi?id=497215 , but not for RDP yet
Lucky day I guess :)
It could be our problem or freerdp problem. Try to run  "xfreerdp /v:<hostname>" and see if it has the same problem.
I'll try to bring up a Fedora Gnome VM to test.