Unsolved "Read access violation" exception
-
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:
- Does anybody see the problem or can tell me what to look for?
- What would you do in order to debug this further and better diagnose the problem?
Thanks!
-
@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.
Followtemp
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?
-
@Bart_Vandewoestyne said in "Read access violation" exception:
QNetworkAccessManager
Do you create a QNetworkAccessManager ?
-
@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 asetNetworkAccessManager
and anetworkAccessManager
method... and apparently we are callingQXmlQuery
's destructor (see call stack)...Why were you asking this?