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

Segfault while QTcpSocket is buffering data

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P2: Important
    • 4.7.3
    • 4.7.0
    • Network: Sockets
    • None
    • Linux 2.6.38 - QT Creator 2.0.1 - Qt 4.7.0

    Description

      The qbytearray that acts as the receive buffer for QTcpSocket crashes while performing a memcpy (called by resize)

      The only socket read I perform is in the following slot code:

      void DataFeed::readData(void)
      {
         //cout << "Reading data from device in slot..." << endl;
         QByteArray *pData = new QByteArray;
         *pData = mp_socket->readAll();
         emit postData(pData);
      }
      

      Here is my connection to the slot:

      connect(mp_socket, SIGNAL(readyRead()), this, SLOT(readData()));
      

      Here is my stack trace, from what I can tell the error is not generated because of my code or is related to the QByteArray I create on the heap.

      0	memcpy	/lib/x86_64-linux-gnu/libc.so.6	0	0x00007ffff66a6abb	
      1	QByteArray::realloc	qbytearray.cpp	1424	0x00007ffff73fd56b	
      2	QByteArray::resize	qbytearray.cpp	1389	0x00007ffff73fd9a9	
      3	QRingBuffer::reserve	qringbuffer_p.h	158	0x00007ffff791e6df	
      4	QAbstractSocketPrivate::readFromSocket	qabstractsocket.cpp	1158	0x00007ffff791912f	
      5	QAbstractSocketPrivate::canReadNotification	qabstractsocket.cpp	614	0x00007ffff79194f5	
      6	QReadNotifier::event	qnativesocketengine.cpp	1103	0x00007ffff7908791	
      7	QCoreApplicationPrivate::notify_helper	qcoreapplication.cpp	867	0x00007ffff75024cf	
      8	QCoreApplication::notify	qcoreapplication.cpp	813	0x00007ffff750254e	
      9	QCoreApplication::notifyInternal	qcoreapplication.cpp	732	0x00007ffff75020a4	
      10	sendEvent	qcoreapplication.h	215	0x00007ffff752fa3a	
      11	socketNotifierSourceDispatch	qeventdispatcher_glib.cpp	110	0x00007ffff752fa3a	
      12	g_main_context_dispatch	/lib/x86_64-linux-gnu/libglib-2.0.so.0	0	0x00007ffff5d5ebcd	
      13	??	/lib/x86_64-linux-gnu/libglib-2.0.so.0	0	0x00007ffff5d5f3a8	
      14	g_main_context_iteration	/lib/x86_64-linux-gnu/libglib-2.0.so.0	0	0x00007ffff5d5f639	
      15	QEventDispatcherGlib::processEvents	qeventdispatcher_glib.cpp	415	0x00007ffff752fbcc	
      16	QEventLoop::processEvents	qeventloop.cpp	149	0x00007ffff75013f5	
      17	QEventLoop::exec	qeventloop.cpp	201	0x00007ffff7501646	
      18	QThread::exec	qthread.cpp	490	0x00007ffff73f8014	
      19	DataFeed::run	datafeed.cpp	103	0x000000000040c477	
      20	QThreadPrivate::start	qthread_unix.cpp	266	0x00007ffff73faf5f	
      21	start_thread	/lib/x86_64-linux-gnu/libpthread.so.0	0	0x00007ffff7157d8c	
      22	clone	/lib/x86_64-linux-gnu/libc.so.6	0	0x00007ffff670204d	
      23	??		0	0x0000000000000000	
      

      Attachments

        1. header.h
          0.7 kB
          xenome
        2. main.cpp
          4 kB
          xenome
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            earthdomain Earth Domain (Inactive)
            xenome xenome
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes