LoadSkin causes ASSERT on exit in another DLL |
Post Reply |
Author | |
g_j_a_i_n
Groupie Joined: 27 August 2005 Status: Offline Points: 91 |
Post Options
Thanks(0)
Posted: 05 March 2012 at 5:31am |
Hello, I have a MFC project which is dependent on another dll. In the exe I call LoadSkin. Everything works fine. But when I exit, it ASSERTS inside the dll code. BOOL WINAPI RawDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID) { hInstance; if (dwReason == DLL_PROCESS_ATTACH) { #ifdef _AFXDLL // make sure we have enough memory to attempt to start (8kb) void* pMinHeap = LocalAlloc(NONZEROLPTR, 0x2000); if (pMinHeap == NULL) return FALSE; // fail if memory alloc fails LocalFree(pMinHeap); // set module state before initialization _AFX_THREAD_STATE* pState = AfxGetThreadState(); pState->m_pPrevModuleState = AfxSetModuleState(&afxModuleState); } else if (dwReason == DLL_PROCESS_DETACH && !__mixedModuleStartup) { // restore module state after cleanup _AFX_THREAD_STATE* pState = AfxGetThreadState(); Here >> VERIFY(AfxSetModuleState(pState->m_pPrevModuleState) == &afxModuleState); DEBUG_ONLY(pState->m_pPrevModuleState = NULL); #endif //_AFXDLL } return TRUE; } When I don't use SkinFramework (comment LoadSkin line), this ASSERT does not happen. Please help. Regards, Gautam Jain |
|
tim00005
Newbie Joined: 23 July 2013 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Hi is there any update to this? I am just about to start debugging the same problem. Code Jock version 16.2.0. VS 2012.
Cheers, Tim. |
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
Hi;
Try this in your ExitInstance() function: int CMyCoreApp::ExitInstance() { XTPSkinManager()->LoadSkin(L"", L""); return CWinApp::ExitInstance(); } I've several DLLs used in my app and skinning too. But in my case the app closes without an assert. |
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
tim00005
Newbie Joined: 23 July 2013 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Hi, thanks for the help.
I am not sure what happened but the assert no longer happens and the app closes correctly. I did change a number of project settings for different reasons so I guess it could be project settings related. If it reappears I will try your suggestion. Hopefully I won't have to. Tim.
|
|
mgampi
Senior Member Joined: 14 July 2003 Status: Offline Points: 1201 |
Post Options
Thanks(0)
|
Hi,
Would be fine if you could tell us more about your changed project settings. |
|
Martin Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0 Platform: Windows 10 v 22H2 (64bit) Language: VC++ 2022 |
|
tim00005
Newbie Joined: 23 July 2013 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Sorry for the delay getting back on this - I have been away.
It was not project settings in the end, I noticed I was building in release so was not getting the assertion - duh. However i have found a solution: I was subclassing the m_hWndMDIClient in CMainFrame::CreateClient. If I call UnsubclassWindow in CMainFrame::OnDestroy then the problem goes away. |
|
tim00005
Newbie Joined: 23 July 2013 Status: Offline Points: 6 |
Post Options
Thanks(0)
|
Scrap that - too quick on the post. Just tried again and it is still here. I give up:)
|
|
Kalyani
Newbie Joined: 13 November 2013 Location: Pune Status: Offline Points: 7 |
Post Options
Thanks(0)
|
Hi,
I am facing the same problem of crash in: it ASSERTS inside the dll code. BOOL WINAPI RawDllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID) { hInstance; if (dwReason == DLL_PROCESS_ATTACH) { #ifdef _AFXDLL // make sure we have enough memory to attempt to start (8kb) void* pMinHeap = LocalAlloc(NONZEROLPTR, 0x2000); if (pMinHeap == NULL) return FALSE; // fail if memory alloc fails LocalFree(pMinHeap); // set module state before initialization _AFX_THREAD_STATE* pState = AfxGetThreadState(); pState->m_pPrevModuleState = AfxSetModuleState(&afxModuleState); } else if (dwReason == DLL_PROCESS_DETACH && !__mixedModuleStartup) { // restore module state after cleanup _AFX_THREAD_STATE* pState = AfxGetThreadState(); Here >> VERIFY(AfxSetModuleState(pState->m_pPrevModuleState) == &afxModuleState); DEBUG_ONLY(pState->m_pPrevModuleState = NULL); #endif //_AFXDLL } return TRUE; } I am not sure of the reason, I commented the loadskin code as suggested here, but it still crashes.
It happens only in Debug mode of my application. PS: codejock v16.2.6 and Visual Studio 2010, Windows 7 64bit Request you to please help me wth the same. Regards, Kalyani |
|
Kalyani
Newbie Joined: 13 November 2013 Location: Pune Status: Offline Points: 7 |
Post Options
Thanks(0)
|
Hi,
Any update on above problem? Regards, Kalyani |
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
Did anyone solve this?
It appears the module state has not been correctly managed. Would adding the AFX_MANAGE_SATE macro in your routine that loads the skin help? Also, with side by side MFC modules, I have found that one can mess up module states if an access violation or some other exception occurs and the module state switching that should occur doesn't happen. But usually I get an invalid context activation exception eventually when it does. Of course you are shutting down (?) and that might not happen. I use the debugger and turn on first chance exception handling (win32, in particular access violations but usually just all) and then run my workflow and see if I am trapping some exception we have been ignoring, say with catch(...). |
|
mcmastl
Admin Group Joined: 14 April 2015 Status: Offline Points: 79 |
Post Options
Thanks(0)
|
Thank you all for bringing this to our attention, we have informed our development team and we will be looking into the issue. If the matter has been resolved please let us know.
|
|
Luke McMasters, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
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 |