App Hangs in CXTPSoundManager |
Post Reply |
Author | |
cpede
Senior Member Joined: 13 August 2004 Location: Denmark Status: Offline Points: 668 |
Post Options
Thanks(0)
Posted: 09 February 2016 at 10:42am |
I have seen a problem when closing down my application. It sometimes hangs in the WaitForSingleObject in the following code in XTPSystemHelpers:
void CXTPSoundManager::StopThread() { if (NULL != m_hThread) { PostThreadMessage(m_dwThreadId, WM_QUIT, 0, 0); ::WaitForSingleObject(m_hThread, INFINITE); ::CloseHandle(m_hThread); m_hThread = 0; m_dwThreadId = 0; } } I'm not using sound, but it think that the code is always called by v17.0.0. I'm I the only one seeing this problem? -cpede
|
|
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64) Language: Visual Studio 2017 (C++) |
|
SvenC
Groupie Joined: 02 February 2007 Status: Offline Points: 79 |
Post Options
Thanks(0)
|
Did you check what the thread with id m_dwThreadId is doing?
|
|
--
SvenC Toolkit Pro 15.3.1, 16.2.4, 16.3.1, 16.4.0, 17.2.0, 17.3.0, 18.0.1, 18.2 with VC++ 2010, 2012, 2013, 2015, 2017 |
|
cpede
Senior Member Joined: 13 August 2004 Location: Denmark Status: Offline Points: 668 |
Post Options
Thanks(0)
|
I have found that the problem lies in the stopping of the sound manager thread from a DLL.
It seems that a DLL opened using LoadLibrary creates a new instance of the CXTPSoundManager* AFX_CDECL XTPSoundManager() and then calls a new instance of the sound thread in void CXTPSoundManager::StartThread(). So now there is a sound manager for the main application and one for each DLL loaded calling e.g. CXTPCommandBars::TrackPopupMenu. Then it seem that unloading the DLL calls void CXTPSoundManager::StopThread(), but the WM_QUIT thread message send to the SoundThreadProc is never received. Any ideas? Should I do something about XTPCommandBars in the InitInstance of the DLLs. Can I call CXTPSoundManager::StopThread() earlier from the DLLs? -cpede
|
|
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64) Language: Visual Studio 2017 (C++) |
|
cpede
Senior Member Joined: 13 August 2004 Location: Denmark Status: Offline Points: 668 |
Post Options
Thanks(0)
|
I can see that the code for void CXTPSoundManager::StopThread() has changed a lot since v15.3.1.
I think the problem is related to loader lock of the DLL, meaning that the thread events are somehow locked, during exiting the DLL. Looking at the v15.3.1 code it always eventually calls TerminateThread in the DLLs, most likely since the GetExitCodeThread does not return the correct exit code. CJ probably needs to look at similar constructions for ending threads, and avoiding INFINITE waits. -cpede
|
|
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64) Language: Visual Studio 2017 (C++) |
|
cpede
Senior Member Joined: 13 August 2004 Location: Denmark Status: Offline Points: 668 |
Post Options
Thanks(0)
|
This problem still exist in v1720.
My call-stack looks like this: It happens when I try to unload a DLL using ::FreeLibrary. Just noted this parallel thread: Could that cause some kind of lock? -cpede
|
|
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64) Language: Visual Studio 2017 (C++) |
|
cpede
Senior Member Joined: 13 August 2004 Location: Denmark Status: Offline Points: 668 |
Post Options
Thanks(0)
|
Anyone looked at this problem?
-cpede
|
|
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64) Language: Visual Studio 2017 (C++) |
|
cpede
Senior Member Joined: 13 August 2004 Location: Denmark Status: Offline Points: 668 |
Post Options
Thanks(0)
|
Am I really the only one having this problem?
The PostThreadMessage does not get through unless a Sleep or WaitForSingleObject is forcing a thread shift? The correction above works in all cases also when freeing a DLL. -cpede
|
|
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64) Language: Visual Studio 2017 (C++) |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |