Valgrind and empty qlist of qpolygonf signal/slot



  • I see this in qt 4.7.4 - at first I ignored it but 0 bytes after a block is still bad (out by one) according to http://valgrind.org/gallery/linux_mag.html listing 2.

    I can work around it but is this a problem in more recent versions?

    ==5581== Invalid read of size 1
    ==5581== at 0x804C754: QList<QPolygonF>::QList(QList<QPolygonF> const&) (in /home/lmcbeath/work/max/qt-everywhere-opensource-src-4.7.4_max_native/demos/declarative/minehunt/minehunt)
    ==5581== by 0x804CE28: MinehuntGame::qt_metacall(QMetaObject::Call, int, void**) (moc_minehunt.cpp:246)
    ==5581== by 0x51CE8F7: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (qmetaobject.cpp:237)
    ==5581== by 0x51DCA8E: QMetaCallEvent::placeMetaCall(QObject*) (qobject.cpp:535)
    ==5581== by 0x51DD716: QObject::event(QEvent*) (qobject.cpp:1217)
    ==5581== by 0x45AE5A3: QApplicationPrivate::notify_helper(QObject*, QEvent*) (qapplication.cpp:4481)
    ==5581== by 0x45AC059: QApplication::notify(QObject*, QEvent*) (qapplication.cpp:3881)
    ==5581== by 0x51C749D: QCoreApplication::notifyInternal(QObject*, QEvent*) (qcoreapplication.cpp:787)
    ==5581== by 0x4141694: QCoreApplication::sendEvent(QObject*, QEvent*) (in /home/lmcbeath/work/max/qt-everywhere-opensource-src-4.7.4_max_native/installed_files/lib/libQtDeclarative.so.4.7.4)
    ==5581== by 0x51C8491: QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (qcoreapplication.cpp:1428)
    ==5581== by 0x51C8188: QCoreApplication::sendPostedEvents(QObject*, int) (qcoreapplication.cpp:1321)
    ==5581== by 0x4662053: QCoreApplication::sendPostedEvents() (qcoreapplication.h:220)
    ==5581== by 0x466CD43: QEventDispatcherX11::processEvents(QFlagsQEventLoop::ProcessEventsFlag) (qeventdispatcher_x11.cpp:75)
    ==5581== by 0x51C52D4: QEventLoop::processEvents(QFlagsQEventLoop::ProcessEventsFlag) (qeventloop.cpp:149)
    ==5581== by 0x51C5418: QEventLoop::exec(QFlagsQEventLoop::ProcessEventsFlag) (qeventloop.cpp:201)
    ==5581== by 0x51C7B1D: QCoreApplication::exec() (qcoreapplication.cpp:1064)
    ==5581== by 0x45ABD05: QApplication::exec() (qapplication.cpp:3755)
    ==5581== by 0x804A0A3: main (main.cpp:86)
    ==5581== Address 0x77681c0 is 0 bytes after a block of size 16 alloc'd
    ==5581== at 0x402BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
    ==5581== by 0x50B6074: qMalloc(unsigned int) (qmalloc.cpp:55)
    ==5581== by 0x511F106: QVectorData::allocate(int, int) (qvector.cpp:67)
    ==5581== by 0x804A8F4: QVector<QPointF>::malloc(int) (qvector.h:393)
    ==5581== by 0x804AC1D: QVector<QPointF>::realloc(int, int) (qvector.h:470)
    ==5581== by 0x804A8B8: QVector<QPointF>::detach_helper() (qvector.h:325)
    ==5581== by 0x804A5CF: QVector<QPointF>::QVector(QVector<QPointF> const&) (in /home/lmcbeath/work/max/qt-everywhere-opensource-src-4.7.4_max_native/demos/declarative/minehunt/minehunt)
    ==5581== by 0x804A4BF: QPolygonF::QPolygonF(QPolygonF const&) (qpolygon.h:138)
    ==5581== by 0x804AA5B: void* qMetaTypeConstructHelper<QPolygonF>(QPolygonF const*) (qmetatype.h:142)
    ==5581== by 0x51D5CED: QMetaType::construct(int, void const*) (qmetatype.cpp:1236)
    ==5581== by 0x51E0B81: queued_activate(QObject*, int, QObjectPrivate::Connection*, void**, QSemaphore*) (qobject.cpp:3149)
    ==5581== by 0x51E0FC8: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (qobject.cpp:3249)
    ==5581== by 0x804D2E9: Proxy::polys(QList<QPolygonF>) (moc_Proxy.cpp:91)
    ==5581== by 0x804C687: Proxy::OnTimer() (Proxy.cpp:14)
    ==5581== by 0x804D287: Proxy::qt_metacall(QMetaObject::Call, int, void**) (moc_Proxy.cpp:79)
    ==5581== by 0x51CE8F7: QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) (qmetaobject.cpp:237)
    ==5581== by 0x51E10CE: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (qobject.cpp:3278)
    ==5581== by 0x51E98E4: QSingleShotTimer::timeout() (qtimer.moc:82)
    ==5581== by 0x51E9799: QSingleShotTimer::timerEvent(QTimerEvent*) (qtimer.cpp:308)
    ==5581== by 0x51DD66B: QObject::event(QEvent*) (qobject.cpp:1181)



  • @
    cat Proxy.h

    #include <QObject>
    #include <QList>
    #include <QPolygonF>

    class Proxy : public QObject
    {
    Q_OBJECT

    public slots:
    void Init();
    void OnTimer();

    signals:
    void polys(QList<QPolygonF> pols);

    };

    @

    @
    cat Proxy.cpp
    #include "Proxy.h"

    #include <QTimer>

    void Proxy::Init()
    {
    QTimer::singleShot(2000, this, SLOT(OnTimer()));
    }

    void Proxy::OnTimer()
    {
    QList<QPolygonF> list;

    emit polys(list);
    }
    @

    @
    void MinehuntGame::TakePolys(QList<QPolygonF> poly)
    {
    std::cout << "polys " << poly.count() << std::endl;
    }

    @

    @
    MinehuntGame* game = new MinehuntGame();
    Proxy *proxy = new Proxy();

    QThread *thread = new QThread();
    proxy->moveToThread(thread);
    proxy->connect(thread, SIGNAL(started()), proxy, SLOT(Init()));
    
    thread->start();
    
    game->connect(proxy, SIGNAL(polys(QList<QPolygonF>)), game, SLOT(TakePolys(QList<QPolygonF>)));
    

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.