Results 1 to 5 of 5

Thread: Active Qt: crash while unloading Qt Core DLL

  1. #1
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Active Qt: crash while unloading Qt Core DLL

    Hi guys,

    I have Qt (5.2.1) GUI application which I'm trying to expose as an ActiveX control. As usual after dll is built I call idc.exe to generate IDL. The problem is idc.exe always crashes on unloading QtCore.dll.

    The main widget have some initialization/finalization code which is required for app to work. This code at some point create QRegEx object, which inside Qt leads to initializing QRegExpEngine and putting it to global static QCache hash.

    Here is the stack trace:

    Qt Code:
    1. Qt5Cored.dll!QGenericAtomicOps<QAtomicOpsBySize<4> >::load<long>(const long & _q_value) Line 96 C++
    2. Qt5Cored.dll!QBasicAtomicInteger<int>::load() Line 142 C++
    3. Qt5Cored.dll!QtPrivate::RefCount::deref() Line 66 C++
    4. Qt5Cored.dll!QString::~QString() Line 921 C++
    5. Qt5Cored.dll!QRegExpEngineKey::~QRegExpEngineKey() C++
    6. Qt5Cored.dll!QHashNode<QRegExpEngineKey,QCache<QRegExpEngineKey,QRegExpEngine>::Node>::~QHashNode<QRegExpEngineKey,QCache<QRegExpEngineKey,QRegExpEngine>::Node>() C++
    7. Qt5Cored.dll!QHashNode<QRegExpEngineKey,QCache<QRegExpEngineKey,QRegExpEngine>::Node>::`scalar deleting destructor'(unsigned int) C++
    8. Qt5Cored.dll!QHash<QRegExpEngineKey,QCache<QRegExpEngineKey,QRegExpEngine>::Node>::deleteNode2(QHashData::Node * node) Line 544 C++
    9. Qt5Cored.dll!QHashData::free_helper(void (QHashData::Node *) * node_delete) Line 423 C++
    10. Qt5Cored.dll!QHash<QRegExpEngineKey,QCache<QRegExpEngineKey,QRegExpEngine>::Node>::freeData(QHashData * x) Line 590 C++
    11. Qt5Cored.dll!QHash<QRegExpEngineKey,QCache<QRegExpEngineKey,QRegExpEngine>::Node>::~QHash<QRegExpEngineKey,QCache<QRegExpEngineKey,QRegExpEngine>::Node>() Line 301 C++
    12. Qt5Cored.dll!QHash<QRegExpEngineKey,QCache<QRegExpEngineKey,QRegExpEngine>::Node>::clear() Line 596 C++
    13. Qt5Cored.dll!QCache<QRegExpEngineKey,QRegExpEngine>::clear() Line 127 C++
    14. Qt5Cored.dll!QCache<QRegExpEngineKey,QRegExpEngine>::~QCache<QRegExpEngineKey,QRegExpEngine>() Line 95 C++
    15. Qt5Cored.dll!QCache<QRegExpEngineKey,QRegExpEngine>::`scalar deleting destructor'(unsigned int) C++
    16. Qt5Cored.dll!``anonymous namespace'::Q_QGS_globalEngineCache::innerFunction'::`8'::Cleanup::~Cleanup() Line 3825 C++
    17. Qt5Cored.dll!``anonymous namespace'::Q_QGS_globalEngineCache::innerFunction'::`9'::`dynamic atexit destructor for 'cleanup''() C++
    18. Qt5Cored.dll!_CRT_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 416 C
    19. Qt5Cored.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 522 C
    20. Qt5Cored.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 472 C
    21. ntdll.dll!776699a0() Unknown
    22. [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
    23. ntdll.dll!7767d702() Unknown
    24. ntdll.dll!7767d5a4() Unknown
    25. kernel32.dll!770279ed() Unknown
    26. msvcr110.dll!__crtExitProcess(int status) Line 725 C
    27. msvcr110.dll!doexit(int code, int quick, int retcaller) Line 627 C
    28. msvcr110.dll!exit(int code) Line 395 C
    29. idc.exe!00e32f73() Unknown
    30. kernel32.dll!7702338a() Unknown
    31. ntdll.dll!77669f72() Unknown
    32. ntdll.dll!77669f45() Unknown
    To copy to clipboard, switch view to plain text mode 

    Any ideas?

    Thank you!

    Kind regards, Ivan

  2. #2
    Join Date
    Jul 2012
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Active Qt: crash while unloading Qt Core DLL

    Your Qt5Cored.dll does not match your Qt5Ax* dlls. Make sure they are loaded from the same qt build.

  3. #3
    Join Date
    May 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Active Qt: crash while unloading Qt Core DLL

    Unfortunately that's not the cause. Qt5Ax* are static libraries, there are no dlls. I double checked there are only one version of Qt on the machine.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Active Qt: crash while unloading Qt Core DLL

    Are you sure you are linking all debug DLLs and static libraries? And that your Ax DLL itself is built as debug? Your stack trace shows that is is a debug version of Qt5Core DLL where the error occurs. You can't mix and match debug and release on Windows.

    Another source of QString errors is mixing builds with wchar_t as a built-in type with wchar_t as a #defined name (/Zwchar_t vs /Zwchar_t-) compile-time options.

  5. #5
    Join Date
    Jul 2012
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Active Qt: crash while unloading Qt Core DLL

    Problem is solved. Reason was: QRegExp object was created from QStringLiteral string. So it is a static initialization order fiasco. QRegExp puts this string to its EngineCache (that is also static and is created earlier than the static string from QStringLiteral). So we came to EngineCache destructor when our static string is already destroyed.

  6. The following user says thank you to Grey DeMonstr for this useful post:

    Cupidvogel (2nd March 2016)

Similar Threads

  1. Replies: 1
    Last Post: 26th December 2014, 14:05
  2. Qt GUI and Qt Core
    By SSqt5.2 in forum Newbie
    Replies: 1
    Last Post: 6th November 2014, 09:39
  3. Core C++ and QML App
    By west in forum Newbie
    Replies: 1
    Last Post: 16th April 2014, 13:11
  4. How to set the QTIMER active only once ?
    By wter27 in forum Qt Programming
    Replies: 3
    Last Post: 28th February 2011, 09:06
  5. Remove library after unloading
    By mvw in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2010, 10:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.