Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Assert on shutdown
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Assert on shutdown

 Post Reply Post Reply
Author
Message
angelsoriasanagustin View Drop Down
Groupie
Groupie


Joined: 16 September 2015
Location: Spain
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote angelsoriasanagustin Quote  Post ReplyReply Direct Link To This Post Topic: Assert on shutdown
    Posted: 06 June 2023 at 10:48am
Hi.

Visual Studio 2022 ( 17.6.2 )
CodeJock Toolkit 22.1
Library linked as static.

When program closes I have an Assert at: CXTPMarkupObject::~CXTPMarkupObject()

SAFE_DELETE(m_pComInitializer);

m_pComInitializer is NULL.

I have read a similar post for older versions, but the suggested fix is already in this version.

Same code with 22.0 version doesn't throw any exception.
CXTPMarkupObject::~CXTPMarkupObject() is not called.

Any solution ?

Thanks.
Back to Top
angelsoriasanagustin View Drop Down
Groupie
Groupie


Joined: 16 September 2015
Location: Spain
Status: Offline
Points: 46
Post Options Post Options   Thanks (0) Thanks(0)   Quote angelsoriasanagustin Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2023 at 8:08am
Hi.

Any news ?
Back to Top
JonN View Drop Down
Newbie
Newbie
Avatar

Joined: 11 January 2004
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote JonN Quote  Post ReplyReply Direct Link To This Post Posted: 22 June 2023 at 11:59am
Hi,

I am experiencing a similar issue. I too get an assert during shutdown of a program. Ity appears to be generated from the destructor CXTPSingletonPointer::~CXTPSingletonPointer() which then calls through several functions including CXTPMarkupType::CClassList::~CClassList() where in this function the code iterates through the list below.  The assert is called during the typeEntry.GetType() call when the key is "FrameworkContentElement"

CXTPMarkupType::CClassList::~CClassList()
{
POSITION pos = m_namedTypes.GetStartPosition();
while (NULL != pos)
{
LPCWSTR key = NULL;
CClassList::CTypeEntry typeEntry;
m_namedTypes.GetNextAssoc(pos, key, typeEntry);

CXTPMarkupType* pType = typeEntry.GetType();
MARKUP_RELEASE(pType);
}

pos = m_unnamedTypes.GetHeadPosition();
while (NULL != pos)
{
CXTPMarkupType* pType = m_unnamedTypes.GetNext(pos).GetType();
MARKUP_RELEASE(pType);
}
}

GetType is listed as

CXTPMarkupType* CXTPMarkupType::CClassList::CTypeEntry::GetType() const
{
if (NULL == m_pType)
{
ASSERT(NULL != m_pfnGetType);
m_pType = m_pfnGetType();
}

return m_pType;
}

The error would appear to be in the line m_pType = m_pfnGetType();  Tracking this through eventually leads to an EnterCriticalSection which fails with an access violation error.

I had not noticed this with earlier versions which in version 19.3 seem to be identical to CXTPSingletonPointer::~CXTPSingletonPointer() and the two functions quoted above.  

A solution would be appreciated please.

Jon
Back to Top
essess View Drop Down
Newbie
Newbie


Joined: 25 June 2023
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote essess Quote  Post ReplyReply Direct Link To This Post Posted: 25 June 2023 at 6:05am
We are experiencing the same issue after upgrading from Toolkit Pro 19.3.0 to 22.1.0.

In our case the crash happens when calling FreeLibrary on a DLL module on shutdown.
However, the crash only happens if we call CXTPPaintManager::SetTheme(office2016) or similar style in the DLL module.

If we don't style controls in the loaded DLL then there is no Access Violation on shutdown.
Back to Top
Radix View Drop Down
Newbie
Newbie


Joined: 02 July 2023
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Radix Quote  Post ReplyReply Direct Link To This Post Posted: 02 July 2023 at 10:29pm
Also experiencing the same - coming from ToolkitPro 20.3.0 which was fine, but now getting crashes when closing my application after the upgrade:

  ntdll.dll!RtlpWaitOnCriticalSection() Unknown
  ntdll.dll!RtlpEnterCriticalSectionContended() Unknown
  ntdll.dll!RtlEnterCriticalSection() Unknown
  MOSESMotions.exe!CXTPMarkupFrameworkContentElement::GetCXTPMarkupFrameworkContentElementType(void) Unknown
  MOSESMotions.exe!CXTPMarkupType::CClassList::CTypeEntry::GetType(void) Unknown
  MOSESMotions.exe!CXTPMarkupType::CClassList::~CClassList(void) Unknown
  MOSESMotions.exe!CXTPSingletonPointer::Destroy(void) Unknown
  MOSESMotions.exe!CXTPSingletonPointer::~CXTPSingletonPointer(void) Unknown
  ucrtbase.dll!<lambda>(void)() Unknown
  ucrtbase.dll!__crt_seh_guarded_call<int>::operator()<<lambda_7777bce6b2f8c936911f934f8298dc43>,<lambda>(void) &,<lambda>(void)>() Unknown
  ucrtbase.dll!_execute_onexit_table() Unknown
  ucrtbase.dll!<lambda>(void)() Unknown
  ucrtbase.dll!__crt_seh_guarded_call<void>::operator()<<lambda_123965863b7b46a3332720573f9ce793>,<lambda>(void) &,<lambda>(void)>() Unknown
  ucrtbase.dll!common_exit() Unknown
> MOSESMotions.exe!__scrt_common_main_seh() Line 295 C++
  kernel32.dll!BaseThreadInitThunk() Unknown
  ntdll.dll!RtlUserThreadStart() Unknown

Compile options I'm using:
#define _XTP_INCLUDE_CONTROLS
#define _XTP_INCLUDE_COMMANDBARS
#define _XTP_INCLUDE_DOCKINGPANE
#define _XTP_INCLUDE_RIBBON
#define _XTP_INCLUDE_TABMANAGER
#define _XTP_INCLUDE_PROPERTYGRID

#define _XTP_EXCLUDE_MARKUP
#define _XTP_EXCLUDE_SYNTAXEDIT
#define _XTP_EXCLUDE_CALENDAR
#define _XTP_EXCLUDE_CHART
#define _XTP_EXCLUDE_FLOWGRAPH
#define _XTP_EXCLUDE_GRAPHICLIBRARY
#define _XTP_EXCLUDE_REPORTCONTROL
#define _XTP_EXCLUDE_SHORTCUTBAR
#define _XTP_EXCLUDE_SKINFRAMEWORK
#define _XTP_EXCLUDE_TASKPANEL 
#define _XTP_EXCLUDE_GRIDCONTROL

#define _XTP_STATICLINK

Back to Top
astoyan View Drop Down
Admin Group
Admin Group
Avatar

Joined: 24 August 2013
Status: Offline
Points: 284
Post Options Post Options   Thanks (0) Thanks(0)   Quote astoyan Quote  Post ReplyReply Direct Link To This Post Posted: 03 July 2023 at 9:39am
Thanks everyone for reporting those issues and providing valuable details. It is a known complex problem related to Markup. Unfortunately, due to the nature of the issue it's not reproducible in Codejock samples and it is very specific to various use cases, that's why it takes so long to address it. However we already know most of the causes and are working on the major fix for Markup and related API. We appreciate anyone submitting a sample project that would help us to verify and potentially fix it for that specific use case. You can submit a test project either here or send to support with a reference to the forum thread, even if you have no active maintenance.

Thank you in advance.
Back to Top
essess View Drop Down
Newbie
Newbie


Joined: 25 June 2023
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote essess Quote  Post ReplyReply Direct Link To This Post Posted: 03 July 2023 at 10:27am
I stumpled upon another issue that you might want to consider in your fixes.
I don't know if you are ever meant to call XTPShutdown() yourself, but if you explicitly call XTPShutdown() in an application that has a CXTPStatusBar then an assert is thrown in CXTPSingletonPointer::GetInstance() on shutdown.

You can reproduce this issue with the Samples\CommandBars\DialogSample project  by adding a call to XTPShutdown(), for instance at the end of method CDialogSampleApp::InitInstance(), just before the line return FALSE;.

Method CDialogSampleApp::InitInstance() can be found in the file:
"C:\Program Files (x86)\Codejock Software\MFC\Xtreme ToolkitPro v22.1.0\Samples\CommandBars\DialogSample\DialogSample.cpp", 


Resulting call stack:
> DialogSample.exe!CXTPSingletonPointer::GetInstance() Line 67 C++
  DialogSample.exe!CXTPSingleton<CXTPPaintManager::CGlobalPaintManagerPtr,CXTPSingletonDependencies<CXTPSingleton<CXTPGdiPlus,CXTPSingletonDependencies<CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency>>,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency,CXTPDummySingletonDependency>>::Instance() Line 221 C++
  DialogSample.exe!CXTPPaintManager::ReleaseInstance() Line 296 C++
  DialogSample.exe!CXTPStatusBar::~CXTPStatusBar() Line 141 C++
  [External Code]
  DialogSample.exe!CDialogSampleApp::InitInstance() Line 96 C++
  [External Code]
  DialogSample.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 26 C++

System Information:
Toolkit Pro 22.1.0
Visual Studio 2019
Dynamic Debug - x64
Windows 11 Pro Version 10.0.22621 Build 22621

Back to Top
astoyan View Drop Down
Admin Group
Admin Group
Avatar

Joined: 24 August 2013
Status: Offline
Points: 284
Post Options Post Options   Thanks (0) Thanks(0)   Quote astoyan Quote  Post ReplyReply Direct Link To This Post Posted: 03 July 2023 at 10:58am
If the main application class is derived from CXTPWinApp then XTPShutdown must not be called.
It is highly recommended to derive CXTPWinApp class because it encapsulates proper ToolkitPro initialization and termination logic. Older ToolkitPro versions didn't use much of it, but future versions will have more important initialization logic added to it, including proper Markup and COM/OLE initialization sequence that is being discussed in this topic.
Back to Top
Radix View Drop Down
Newbie
Newbie


Joined: 02 July 2023
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote Radix Quote  Post ReplyReply Direct Link To This Post Posted: 06 July 2023 at 9:34pm
I'm guessing the Markup code doesn't properly check for #define _XTP_EXCLUDE_MARKUP then





Back to Top
timop View Drop Down
Newbie
Newbie
Avatar

Joined: 10 March 2021
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote timop Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2023 at 3:37pm
I have also assert when XTP_DECLARE_MARKUP_STRING_CONSTANT is used.
Ctor of CXTPMarkupString specifies "CXTPMarkupObject::flagNoCom", but dtor requires COM. 
When COM is initialized, then there is no assert.



It is already fixed in version 22.1
Back to Top
jmarcosf View Drop Down
Groupie
Groupie


Joined: 22 June 2006
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote jmarcosf Quote  Post ReplyReply Direct Link To This Post Posted: 24 October 2023 at 12:52pm
Hi all,
I am using v22.1 and experienced same problem.
Just in case it helps this is my ExitInstance() method which solved my problem.

int CModule::ExitInstance()
{
     CoUninitialize();
     return CXTPWinApp::ExitInstance();
}
Back to Top
matsjansson View Drop Down
Groupie
Groupie


Joined: 09 May 2023
Location: Solna
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote matsjansson Quote  Post ReplyReply Direct Link To This Post Posted: 02 November 2023 at 10:53am
I had a similar issue, with a crash in EnterCriticalSection connected to some Markup.

The problem was solved by deriving my App class from CXTPWinApp instead of CWinApp.

BUT HOW SHOULD I KNOW THAT I NEED TO DERIVE FROM THAT CLASS????

Is there any documentation at all to read?

Back to Top
astoyan View Drop Down
Admin Group
Admin Group
Avatar

Joined: 24 August 2013
Status: Offline
Points: 284
Post Options Post Options   Thanks (0) Thanks(0)   Quote astoyan Quote  Post ReplyReply Direct Link To This Post Posted: 05 November 2023 at 3:37pm
The initially reported issue and a large number of related issue have been already fixed for the next ToolkitPro update. However it is still possible that some rare use cases remained unaccounted for. 

Originally posted by matsjansson matsjansson wrote:

BUT HOW SHOULD I KNOW THAT I NEED TO DERIVE FROM THAT CLASS????
This has been reflected in the release notes when CXTPWinApp was added. It is also used in all our samples. We always ask our users to refer to our samples for usage examples as most of the use cases are demonstrated there.

Regards,
   Alexander
Back to Top
matsjansson View Drop Down
Groupie
Groupie


Joined: 09 May 2023
Location: Solna
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote matsjansson Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2023 at 7:53am
Ok,
I am new to this tool. I have taken over a project that uses version 10.3.1 and now we have bought v22.1.0.
I have not read all the relase notes from 10.3.1 to now, but maybe I should.

/Mats


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.