Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57202

SIGPIPE during data_source_send can terminate any Qt app

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.9.0 Beta 2
    • 5.7.0
    • QPA: Wayland
    • None

    Description

      Consider the following setup: we have two applications we want to use for copy and paste. A Qt application "copy" which has copied some data to the clipboard.

      And another application "paste" which wants to receive the current clipboard content.

      If the paste application closes the read side of the pipe prior to the copy application having written to it, a SIGPIPE is sent to the copy application which results in a terminate of app.

      See the following backtrace of kwrite:

      Thread 1 "kwrite" received signal SIGPIPE, Broken pipe.
      0x00007ffff266f63d in write () at ../sysdeps/unix/syscall-template.S:84
      84      ../sysdeps/unix/syscall-template.S: No such file or directory.
      (gdb) t a a bt
      
      Thread 2 (Thread 0x7fffe16cb700 (LWP 14172)):
      #0  0x00007ffff267356d in poll () at ../sysdeps/unix/syscall-template.S:84
      #1  0x00007fffec4aa9f6 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #2  0x00007fffec4aab0c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #3  0x00007ffff349290f in QEventDispatcherGlib::processEvents (this=0x7fffdc0008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
      #4  0x00007ffff344090a in QEventLoop::exec (this=this@entry=0x7fffe16cac60, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
      #5  0x00007ffff327648c in QThread::exec (this=this@entry=0x7ffff3714120 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at thread/qthread.cpp:507
      #6  0x00007ffff36a3695 in QDBusConnectionManager::run (this=0x7ffff3714120 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at qdbusconnection.cpp:196
      #7  0x00007ffff327adf9 in QThreadPrivate::start (arg=0x7ffff3714120 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at thread/qthread_unix.cpp:344
      #8  0x00007ffff0055464 in start_thread (arg=0x7fffe16cb700) at pthread_create.c:333
      #9  0x00007ffff267c9df in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:105
      
      Thread 1 (Thread 0x7fffe87b2e80 (LWP 14167)):
      #0  0x00007ffff266f63d in write () at ../sysdeps/unix/syscall-template.S:84
      #1  0x00007fffe841ea50 in QtWaylandClient::QWaylandDataSource::data_source_send (this=<optimized out>, mime_type=..., fd=10) at qwaylanddatasource.cpp:86
      #2  0x00007fffe842f5db in QtWayland::wl_data_source::handle_send (data=0x5555561e38f0, object=<optimized out>, mime_type=0x5555565b39dc "text/plain", fd=10) at qwayland-wayland.cpp:593
      #3  0x00007fffe6828038 in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
      #4  0x00007fffe6827a9a in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
      #5  0x00007fffe7687ece in wl_closure_invoke (closure=closure@entry=0x5555565b3900, flags=flags@entry=1, target=target@entry=0x5555561e4790, opcode=opcode@entry=1, data=0x5555561e38f0) at ../src/connection.c:935
      #6  0x00007fffe7684b90 in dispatch_event (display=display@entry=0x5555557b2c30, queue=0x5555557b2cf8) at ../src/wayland-client.c:1310
      #7  0x00007fffe7685ddc in dispatch_queue (queue=0x5555557b2cf8, display=0x5555557b2c30) at ../src/wayland-client.c:1456
      #8  wl_display_dispatch_queue_pending (display=0x5555557b2c30, queue=0x5555557b2cf8) at ../src/wayland-client.c:1698
      #9  0x00007fffe7685e2c in wl_display_dispatch_pending (display=<optimized out>) at ../src/wayland-client.c:1761
      #10 0x00007fffe84166d2 in QtWaylandClient::QWaylandDisplay::flushRequests (this=0x5555557b2ac0) at qwaylanddisplay.cpp:187
      #11 0x00007ffff346b389 in QMetaObject::activate (sender=sender@entry=0x5555558390f0, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fffffffc9a0) at kernel/qobject.cpp:3740
      #12 0x00007ffff346bd47 in QMetaObject::activate (sender=sender@entry=0x5555558390f0, m=m@entry=0x7ffff3685ac0 <QSocketNotifier::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fffffffc9a0)
          at kernel/qobject.cpp:3602
      #13 0x00007ffff34dfcce in QSocketNotifier::activated (this=this@entry=0x5555558390f0, _t1=3) at .moc/moc_qsocketnotifier.cpp:135
      #14 0x00007ffff347778b in QSocketNotifier::event (this=0x5555558390f0, e=<optimized out>) at kernel/qsocketnotifier.cpp:266
      #15 0x00007ffff3d9822c in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x5555558390f0, e=0x7fffffffcbf0) at kernel/qapplication.cpp:3799
      #16 0x00007ffff3d9f5e6 in QApplication::notify (this=0x7fffffffcf60, receiver=0x5555558390f0, e=0x7fffffffcbf0) at kernel/qapplication.cpp:3556
      #17 0x00007ffff3442398 in QCoreApplication::notifyInternal2 (receiver=0x5555558390f0, event=event@entry=0x7fffffffcbf0) at kernel/qcoreapplication.cpp:988
      #18 0x00007ffff3492dad in QCoreApplication::sendEvent (event=0x7fffffffcbf0, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
      #19 socketNotifierSourceDispatch (source=0x555555839080) at kernel/qeventdispatcher_glib.cpp:106
      #20 0x00007fffec4aa7f7 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #21 0x00007fffec4aaa60 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #22 0x00007fffec4aab0c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #23 0x00007ffff349290f in QEventDispatcherGlib::processEvents (this=0x555555832f10, flags=...) at kernel/qeventdispatcher_glib.cpp:423
      #24 0x00007ffff344090a in QEventLoop::exec (this=this@entry=0x7fffffffce00, flags=..., flags@entry=...) at kernel/qeventloop.cpp:210
      #25 0x00007ffff34488ed in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1261
      #26 0x0000555555561b5f in main ()
      

      To trigger this I used a modified KWayland example application, which is attached. The important part is documented.

      So steps to reproduce
      1. Open KWrite (or any other Qt application) on --platform wayland
      2. Copy something into the clipboard
      3. run attached pasteclient
      4. observe that application from step 1 terminates with SIGPIPE

      Attachments

        1. pasteclient.cpp
          7 kB
          Martin Gräßlin
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            johanhelsing Johan Helsing
            mgraesslin Martin Gräßlin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes