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. "Read access violation" exception
Forum Updated to NodeBB v4.3 + New Features

"Read access violation" exception

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 2.0k 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.
  • B Offline
    B Offline
    Bart_Vandewoestyne
    wrote on last edited by
    #1

    Hello all,

    I am currently breaking my head on a crash (we are using Qt 5.14.0 and Visual Studio 2015). When running one of our Google Test unit tests, the test only sometimes fails (in my case, in 1 out of 4 runs) with an error dialog having the text:

    Exception thrown: read access violation.
    temp-> was 0x4C311B4
    If there is a handler for this exception, the program may be safely continued.
    

    The call stack at the time of the crash looks as follows (note that I renamed some things in order not to reveal company code):

    Qt5Networkd.dll!Microsoft::WRL::ComPtr<IConnectionPoint>::InternalRelease() Line 200
    Qt5Networkd.dll!Microsoft::WRL::ComPtr<IConnectionPoint>::~ComPtr<IConnectionPoint>() Line 256
    Qt5Networkd.dll!QNetworkListManagerEvents::~QNetworkListManagerEvents() Line 560
    [External Code]	
    Qt5Networkd.dll!QNetworkListManagerEvents::Release() Line 482
    Qt5Networkd.dll!Microsoft::WRL::ComPtr<QNetworkListManagerEvents>::InternalRelease() Line 200
    Qt5Networkd.dll!Microsoft::WRL::ComPtr<QNetworkListManagerEvents>::Reset() Line 401
    Qt5Networkd.dll!QNetworkStatusMonitorPrivate::~QNetworkStatusMonitorPrivate() Line 632
    [External Code]	
    Qt5Cored.dll!QScopedPointerDeleter<QObjectData>::cleanup(QObjectData * pointer=0x05342b40) Line 60
    Qt5Cored.dll!QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >::~QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >() Line 107
    Qt5Cored.dll!QObject::~QObject() Line 1119
    Qt5Networkd.dll!QNetworkStatusMonitor::~QNetworkStatusMonitor() Line 667
    Qt5Networkd.dll!QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate() Line 1927
    [External Code]	
    Qt5Cored.dll!QScopedPointerDeleter<QObjectData>::cleanup(QObjectData * pointer=0x05340958) Line 60
    Qt5Cored.dll!QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >::~QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >() Line 107
    Qt5Cored.dll!QObject::~QObject() Line 1119
    Qt5Networkd.dll!QNetworkAccessManager::~QNetworkAccessManager() Line 535
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2123
    Qt5Cored.dll!QObject::~QObject() Line 1110
    [External Code]	
    Qt5XmlPatternsd.dll!QPatternist::ReferenceCountedValue<QObject>::~ReferenceCountedValue<QObject>() Line 87
    [External Code]	
    Qt5XmlPatternsd.dll!QExplicitlySharedDataPointer<QPatternist::ReferenceCountedValue<QObject> >::~QExplicitlySharedDataPointer<QPatternist::ReferenceCountedValue<QObject> >() Line 184
    [External Code]	
    Qt5XmlPatternsd.dll!QXmlQuery::~QXmlQuery() Line 309
    FooBarPlugins_gtest.exe!MyXPathParser::~MyXPathParser() Line 52
    [External Code]	
    FooBarPlugins_gtest.exe!ConfigResultGenerator::~ConfigResultGenerator() Line 77
    [External Code]	
    FooBarPlugins_gtest.exe!MyMockServer::~MyMockServer() Line 61
    [External Code]	
    FooBarPlugins_gtest.exe!MySuperTestWithSimulators::~MySuperTestWithSimulators() Line 142
    [External Code]	
    FooBarPlugins_gtest.exe!testing::Test::DeleteSelf_() Line 492
    FooBarPlugins_gtest.exe!testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,void>(testing::Test * object=0x01219360, void(testing::Test::*)() method=0x009087d3, const char * location=0x00d9bf98) Line 2418
    FooBarPlugins_gtest.exe!testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void>(testing::Test * object=0x01219360, void(testing::Test::*)() method=0x009087d3, const char * location=0x00d9bf98) Line 2469
    FooBarPlugins_gtest.exe!testing::TestInfo::Run() Line 2690
    FooBarPlugins_gtest.exe!testing::TestSuite::Run() Line 2817
    FooBarPlugins_gtest.exe!testing::internal::UnitTestImpl::RunAllTests() Line 5339
    FooBarPlugins_gtest.exe!testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>(testing::internal::UnitTestImpl * object=0x01182490, bool(testing::internal::UnitTestImpl::*)() method=0x00901e01, const char * location=0x00d9e558) Line 2418
    FooBarPlugins_gtest.exe!testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>(testing::internal::UnitTestImpl * object=0x01182490, bool(testing::internal::UnitTestImpl::*)() method=0x00901e01, const char * location=0x00d9e558) Line 2469
    FooBarPlugins_gtest.exe!testing::UnitTest::Run() Line 4925
    FooBarPlugins_gtest.exe!RUN_ALL_TESTS() Line 2474
    FooBarPlugins_gtest.exe!main(int argc=3, char * * argv=0x01181cc8) Line 205
    [External Code]	
    

    The crash seems to occur at the end of the unit test, when the test fixture's destructor gets called. Simplifying things, I think I have the following chain of destructors (from our own code):

    ~MySuperTestWithSimulators()
    => calls ~MyMockServer()
      => calls ~ConfigResultGenerator()
        => calls ~MyXPathParser()
          => calls ~QXmlQuery()
    

    Going even more up the call stack, I no longer encounter code written by us, the rest is third-party.

    Given the fact that the crash only occurs 1 out of 4 times, I think I should be looking for a race-condition. However, I can't seem to find anything suspicious... So given the above error message and call stack, here are my questions:

    1. Does anybody see the problem or can tell me what to look for?
    2. What would you do in order to debug this further and better diagnose the problem?

    Thanks!

    Pl45m4P 1 Reply Last reply
    0
    • B Bart_Vandewoestyne

      Hello all,

      I am currently breaking my head on a crash (we are using Qt 5.14.0 and Visual Studio 2015). When running one of our Google Test unit tests, the test only sometimes fails (in my case, in 1 out of 4 runs) with an error dialog having the text:

      Exception thrown: read access violation.
      temp-> was 0x4C311B4
      If there is a handler for this exception, the program may be safely continued.
      

      The call stack at the time of the crash looks as follows (note that I renamed some things in order not to reveal company code):

      Qt5Networkd.dll!Microsoft::WRL::ComPtr<IConnectionPoint>::InternalRelease() Line 200
      Qt5Networkd.dll!Microsoft::WRL::ComPtr<IConnectionPoint>::~ComPtr<IConnectionPoint>() Line 256
      Qt5Networkd.dll!QNetworkListManagerEvents::~QNetworkListManagerEvents() Line 560
      [External Code]	
      Qt5Networkd.dll!QNetworkListManagerEvents::Release() Line 482
      Qt5Networkd.dll!Microsoft::WRL::ComPtr<QNetworkListManagerEvents>::InternalRelease() Line 200
      Qt5Networkd.dll!Microsoft::WRL::ComPtr<QNetworkListManagerEvents>::Reset() Line 401
      Qt5Networkd.dll!QNetworkStatusMonitorPrivate::~QNetworkStatusMonitorPrivate() Line 632
      [External Code]	
      Qt5Cored.dll!QScopedPointerDeleter<QObjectData>::cleanup(QObjectData * pointer=0x05342b40) Line 60
      Qt5Cored.dll!QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >::~QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >() Line 107
      Qt5Cored.dll!QObject::~QObject() Line 1119
      Qt5Networkd.dll!QNetworkStatusMonitor::~QNetworkStatusMonitor() Line 667
      Qt5Networkd.dll!QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate() Line 1927
      [External Code]	
      Qt5Cored.dll!QScopedPointerDeleter<QObjectData>::cleanup(QObjectData * pointer=0x05340958) Line 60
      Qt5Cored.dll!QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >::~QScopedPointer<QObjectData,QScopedPointerDeleter<QObjectData> >() Line 107
      Qt5Cored.dll!QObject::~QObject() Line 1119
      Qt5Networkd.dll!QNetworkAccessManager::~QNetworkAccessManager() Line 535
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2123
      Qt5Cored.dll!QObject::~QObject() Line 1110
      [External Code]	
      Qt5XmlPatternsd.dll!QPatternist::ReferenceCountedValue<QObject>::~ReferenceCountedValue<QObject>() Line 87
      [External Code]	
      Qt5XmlPatternsd.dll!QExplicitlySharedDataPointer<QPatternist::ReferenceCountedValue<QObject> >::~QExplicitlySharedDataPointer<QPatternist::ReferenceCountedValue<QObject> >() Line 184
      [External Code]	
      Qt5XmlPatternsd.dll!QXmlQuery::~QXmlQuery() Line 309
      FooBarPlugins_gtest.exe!MyXPathParser::~MyXPathParser() Line 52
      [External Code]	
      FooBarPlugins_gtest.exe!ConfigResultGenerator::~ConfigResultGenerator() Line 77
      [External Code]	
      FooBarPlugins_gtest.exe!MyMockServer::~MyMockServer() Line 61
      [External Code]	
      FooBarPlugins_gtest.exe!MySuperTestWithSimulators::~MySuperTestWithSimulators() Line 142
      [External Code]	
      FooBarPlugins_gtest.exe!testing::Test::DeleteSelf_() Line 492
      FooBarPlugins_gtest.exe!testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test,void>(testing::Test * object=0x01219360, void(testing::Test::*)() method=0x009087d3, const char * location=0x00d9bf98) Line 2418
      FooBarPlugins_gtest.exe!testing::internal::HandleExceptionsInMethodIfSupported<testing::Test,void>(testing::Test * object=0x01219360, void(testing::Test::*)() method=0x009087d3, const char * location=0x00d9bf98) Line 2469
      FooBarPlugins_gtest.exe!testing::TestInfo::Run() Line 2690
      FooBarPlugins_gtest.exe!testing::TestSuite::Run() Line 2817
      FooBarPlugins_gtest.exe!testing::internal::UnitTestImpl::RunAllTests() Line 5339
      FooBarPlugins_gtest.exe!testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>(testing::internal::UnitTestImpl * object=0x01182490, bool(testing::internal::UnitTestImpl::*)() method=0x00901e01, const char * location=0x00d9e558) Line 2418
      FooBarPlugins_gtest.exe!testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl,bool>(testing::internal::UnitTestImpl * object=0x01182490, bool(testing::internal::UnitTestImpl::*)() method=0x00901e01, const char * location=0x00d9e558) Line 2469
      FooBarPlugins_gtest.exe!testing::UnitTest::Run() Line 4925
      FooBarPlugins_gtest.exe!RUN_ALL_TESTS() Line 2474
      FooBarPlugins_gtest.exe!main(int argc=3, char * * argv=0x01181cc8) Line 205
      [External Code]	
      

      The crash seems to occur at the end of the unit test, when the test fixture's destructor gets called. Simplifying things, I think I have the following chain of destructors (from our own code):

      ~MySuperTestWithSimulators()
      => calls ~MyMockServer()
        => calls ~ConfigResultGenerator()
          => calls ~MyXPathParser()
            => calls ~QXmlQuery()
      

      Going even more up the call stack, I no longer encounter code written by us, the rest is third-party.

      Given the fact that the crash only occurs 1 out of 4 times, I think I should be looking for a race-condition. However, I can't seem to find anything suspicious... So given the above error message and call stack, here are my questions:

      1. Does anybody see the problem or can tell me what to look for?
      2. What would you do in order to debug this further and better diagnose the problem?

      Thanks!

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @Bart_Vandewoestyne said in "Read access violation" exception:

      Does anybody see the problem or can tell me what to look for?

      Look for redundant deletions. If you try to access or delete an invalid pointer this crash can occur.
      Follow temp and check if memory address changes (where it is called.. destructor etc).

      Does it crash, if you comment some lines in your destructors? Have you figured out in which line exactly the crash occures?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      3
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Bart_Vandewoestyne said in "Read access violation" exception:

        QNetworkAccessManager

        Do you create a QNetworkAccessManager ?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        B 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          @Bart_Vandewoestyne said in "Read access violation" exception:

          QNetworkAccessManager

          Do you create a QNetworkAccessManager ?

          B Offline
          B Offline
          Bart_Vandewoestyne
          wrote on last edited by
          #4

          @Christian-Ehrlicher said in "Read access violation" exception:

          Do you create a QNetworkAccessManager ?

          For as far as I know and can see, 'no'. However, I see that QXmlQuery has a setNetworkAccessManager and a networkAccessManager method... and apparently we are calling QXmlQuery's destructor (see call stack)...

          Why were you asking this?

          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