Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt3D 5.12.0 crash at show/exit when using QText2DEntity msvc2017
Forum Updated to NodeBB v4.3 + New Features

Qt3D 5.12.0 crash at show/exit when using QText2DEntity msvc2017

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 745 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Harold
    wrote on last edited by
    #1

    Hi all,

    I have reproduced a crash with a minimal example happening sometimes when the window is shown, sometimes at application exit.
    The crash appears only if i add a QText2DEntity and only in debug mode, here is the code to reproduce it :

    #include <QGuiApplication>
    #include <Qt3DWindow>
    #include <Qt3DCore/QEntity>
    #include <Qt3DExtras/QText2DEntity>
    
    int main(int argc, char* argv[])
    {
    	QGuiApplication app(argc, argv);
    	Qt3DExtras::Qt3DWindow view;
    
    	QEntity * rootEntity = new QEntity;
    	Qt3DExtras::QText2DEntity * text2D = new Qt3DExtras::QText2DEntity(rootEntity);
    	text2D->setFont(QFont("arial"));
    	text2D->setHeight(25);
    	text2D->setWidth(100);
    	text2D->setText("A");
    	text2D->setColor(Qt::red);
    
    	view.setRootEntity(rootEntity);
    	view.show();
    
    	return app.exec();
    }
    

    Here is the call stack when it crashs at application exit ( closing the window ) :

    Qt5Cored.dll!QMetaObject::cast(const QObject * obj) Line 368
    Qt5Cored.dll!QMetaObject::cast(QObject * obj) Line 358
    Qt53DCored.dll!qobject_cast<Qt3DCore::QNode *>(QObject * object) Line 505
    Qt53DCored.dll!Qt3DCore::QNodeVisitor::traverseChildren<Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> >(Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> & fN) Line 159
    Qt53DCored.dll!Qt3DCore::QNodeVisitor::visitNode<Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> >(Qt3DCore::QNode * nd, Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> & fN) Line 129
    Qt53DCored.dll!Qt3DCore::QNodeVisitor::startTraversing<Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> >(Qt3DCore::QNode * rootNode_, Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> fN) Line 110
    Qt53DCored.dll!Qt3DCore::QNodeVisitor::traverse<Qt3DCore::QNodePrivate,void (__thiscall Qt3DCore::QNodePrivate::*)(Qt3DCore::QNode *)>(Qt3DCore::QNode * rootNode_, Qt3DCore::QNodePrivate * instance, void(Qt3DCore::QNodePrivate::*)(Qt3DCore::QNode *) fN) Line 79
    Qt53DCored.dll!Qt3DCore::QNodePrivate::notifyDestructionChangesAndRemoveFromScene() Line 161
    Qt53DCored.dll!Qt3DCore::QNode::~QNode() Line 754
    Qt53DCored.dll!Qt3DCore::QEntity::~QEntity() Line 113
    [External Code]	
    Qt53DExtrasd.dll!QtSharedPointer::CustomDeleter<Qt3DCore::QEntity,QtSharedPointer::NormalDeleter>::execute() Line 195
    Qt53DExtrasd.dll!QtSharedPointer::ExternalRefCountWithCustomDeleter<Qt3DCore::QEntity,QtSharedPointer::NormalDeleter>::deleter(QtSharedPointer::ExternalRefCountData * self) Line 217
    Qt53DCored.dll!QtSharedPointer::ExternalRefCountData::destroy() Line 157
    Qt53DCored.dll!QSharedPointer<Qt3DCore::QEntity>::deref(QtSharedPointer::ExternalRefCountData * dd) Line 467
    Qt53DCored.dll!QSharedPointer<Qt3DCore::QEntity>::deref() Line 460
    Qt53DCored.dll!QSharedPointer<Qt3DCore::QEntity>::~QSharedPointer<Qt3DCore::QEntity>() Line 315
    Qt53DCored.dll!QSharedPointer<Qt3DCore::QEntity>::operator=(const QSharedPointer<Qt3DCore::QEntity> & other) Line 336
    Qt53DCored.dll!Qt3DCore::QAspectEngine::setRootEntity(QSharedPointer<Qt3DCore::QEntity> root) Line 428
    Qt53DCored.dll!Qt3DCore::QAspectEngine::~QAspectEngine() Line 205
    [External Code]	
    Qt53DExtrasd.dll!Qt3DExtras::Qt3DWindow::~Qt3DWindow() Line 134
    GeckoPrez.exe!main(int argc, char * * argv) Line 41
    

    It seems that during the graph destruction, a cast is done on an already destructed object :

    const QObject *QMetaObject::cast(const QObject *obj) const
    {
        return (obj && obj->metaObject()->inherits(this)) ? obj : nullptr;
    }
    
    Exception thrown: read access violation.
    obj-> was 0xDDDDDDDD.
    

    Any insight ?

    Regards,
    Harold

    kshegunovK 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      No an insight but you should test again against 5.12.1 since it just got released.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • H Harold

        Hi all,

        I have reproduced a crash with a minimal example happening sometimes when the window is shown, sometimes at application exit.
        The crash appears only if i add a QText2DEntity and only in debug mode, here is the code to reproduce it :

        #include <QGuiApplication>
        #include <Qt3DWindow>
        #include <Qt3DCore/QEntity>
        #include <Qt3DExtras/QText2DEntity>
        
        int main(int argc, char* argv[])
        {
        	QGuiApplication app(argc, argv);
        	Qt3DExtras::Qt3DWindow view;
        
        	QEntity * rootEntity = new QEntity;
        	Qt3DExtras::QText2DEntity * text2D = new Qt3DExtras::QText2DEntity(rootEntity);
        	text2D->setFont(QFont("arial"));
        	text2D->setHeight(25);
        	text2D->setWidth(100);
        	text2D->setText("A");
        	text2D->setColor(Qt::red);
        
        	view.setRootEntity(rootEntity);
        	view.show();
        
        	return app.exec();
        }
        

        Here is the call stack when it crashs at application exit ( closing the window ) :

        Qt5Cored.dll!QMetaObject::cast(const QObject * obj) Line 368
        Qt5Cored.dll!QMetaObject::cast(QObject * obj) Line 358
        Qt53DCored.dll!qobject_cast<Qt3DCore::QNode *>(QObject * object) Line 505
        Qt53DCored.dll!Qt3DCore::QNodeVisitor::traverseChildren<Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> >(Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> & fN) Line 159
        Qt53DCored.dll!Qt3DCore::QNodeVisitor::visitNode<Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> >(Qt3DCore::QNode * nd, Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> & fN) Line 129
        Qt53DCored.dll!Qt3DCore::QNodeVisitor::startTraversing<Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> >(Qt3DCore::QNode * rootNode_, Qt3DCore::QNodeVisitor::MemberFunctionFunctor<Qt3DCore::QNodePrivate,void,Qt3DCore::QNode *> fN) Line 110
        Qt53DCored.dll!Qt3DCore::QNodeVisitor::traverse<Qt3DCore::QNodePrivate,void (__thiscall Qt3DCore::QNodePrivate::*)(Qt3DCore::QNode *)>(Qt3DCore::QNode * rootNode_, Qt3DCore::QNodePrivate * instance, void(Qt3DCore::QNodePrivate::*)(Qt3DCore::QNode *) fN) Line 79
        Qt53DCored.dll!Qt3DCore::QNodePrivate::notifyDestructionChangesAndRemoveFromScene() Line 161
        Qt53DCored.dll!Qt3DCore::QNode::~QNode() Line 754
        Qt53DCored.dll!Qt3DCore::QEntity::~QEntity() Line 113
        [External Code]	
        Qt53DExtrasd.dll!QtSharedPointer::CustomDeleter<Qt3DCore::QEntity,QtSharedPointer::NormalDeleter>::execute() Line 195
        Qt53DExtrasd.dll!QtSharedPointer::ExternalRefCountWithCustomDeleter<Qt3DCore::QEntity,QtSharedPointer::NormalDeleter>::deleter(QtSharedPointer::ExternalRefCountData * self) Line 217
        Qt53DCored.dll!QtSharedPointer::ExternalRefCountData::destroy() Line 157
        Qt53DCored.dll!QSharedPointer<Qt3DCore::QEntity>::deref(QtSharedPointer::ExternalRefCountData * dd) Line 467
        Qt53DCored.dll!QSharedPointer<Qt3DCore::QEntity>::deref() Line 460
        Qt53DCored.dll!QSharedPointer<Qt3DCore::QEntity>::~QSharedPointer<Qt3DCore::QEntity>() Line 315
        Qt53DCored.dll!QSharedPointer<Qt3DCore::QEntity>::operator=(const QSharedPointer<Qt3DCore::QEntity> & other) Line 336
        Qt53DCored.dll!Qt3DCore::QAspectEngine::setRootEntity(QSharedPointer<Qt3DCore::QEntity> root) Line 428
        Qt53DCored.dll!Qt3DCore::QAspectEngine::~QAspectEngine() Line 205
        [External Code]	
        Qt53DExtrasd.dll!Qt3DExtras::Qt3DWindow::~Qt3DWindow() Line 134
        GeckoPrez.exe!main(int argc, char * * argv) Line 41
        

        It seems that during the graph destruction, a cast is done on an already destructed object :

        const QObject *QMetaObject::cast(const QObject *obj) const
        {
            return (obj && obj->metaObject()->inherits(this)) ? obj : nullptr;
        }
        
        Exception thrown: read access violation.
        obj-> was 0xDDDDDDDD.
        

        Any insight ?

        Regards,
        Harold

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        Smells like a bug to me.

        Does anything change if you do this:

        QSharedPointer<QEntity> rootEntity(new QEntity);
        

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1
        • H Offline
          H Offline
          Harold
          wrote on last edited by
          #4

          Hi SGaist and kshegunov,

          Thank you for your answers.
          5.12.1 does not help, but wrapping the root entity into a QScopedPointer seems to fix the crash.

          It is weird that Qt3DWindow::setRootEntity takes a raw QEntity pointer as input where QAspectEngine::setRootEntity receives a QEntityPtr ( which is a QSharedPointer<QEntity> ).
          Intuitively we assume that Qt3DWindow::setRootEntity will take the ownership of the pointer.

          Well, black magic to me :p

          Thank you for you help.

          Regards,
          Harold

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DavidFaure
            wrote last edited by DavidFaure
            #5

            In case anyone lands here, I just fixed a crash in QNodeVisitor::traverseChildren: https://codereview.qt-project.org/c/qt/qt3d/+/656476

            SGaistS 1 Reply Last reply
            2
            • D DavidFaure

              In case anyone lands here, I just fixed a crash in QNodeVisitor::traverseChildren: https://codereview.qt-project.org/c/qt/qt3d/+/656476

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote last edited by
              #6

              @DavidFaure that was a sneaky one !

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved