C ++应用程序崩溃并出现atexit()错误

时间:2019-01-18 11:33:34

标签: c++ mfc atexit

我们有一个使用MFC并用c ++编写的安装应用程序,它在粘贴调用堆栈时间歇性崩溃。此应用程序即将完成时,将发生崩溃。我们可以在调用堆栈中看到带有静态变量“ svUniqueUpdates”的atexit()引用,该变量在函数内部用于某些计算。这次崩溃确实是由atexit()引起的以及如何解决?

调用堆栈

0 Id:3f30.8d0挂起:1 Teb:00000090 bbdf7000 Unfrozen # Child-SP RetAddr : Args to Child : Call Site 00 00000090 bc1ffba8 00007ffa 7cc507b3 : 00000000 00000000 00007ff6 1fec2370 0000b408 eb7e3e32 00007ffa 7fa05d78 : Install! TotalUpdCount':: 2':: svUpdates的动态atexit析构函数 01 00000090 bc1ffbb0 00007ffa 7cc4ce0b:00000090 bc1ffd00 00000090 bc1ffc88 00000090 bc1ffd20 00007ffa 7cd25c80:ucrtbase!:: operator()+ 0xc3 02 00000090 bc1ffc10 00007ffa 7cc506e4:00000090 bc1ffd08 00007ffa 7cd25c80 00000000 00000000 00000090 bc1ffc78:ucrtbase!__ crt_seh_guarded_call :: operator()<,&__ptr64,> + 0x3b 03 00000090 bc1ffc40 00007ffa 7cc5bb69:00007ffa 7cd260a8 00007ffa 00000002 00000000 00000002 00000090 bc1ffc70:ucrtbase!execute_onexit_table + 0x34 04 00000090 bc1ffc70 00007ffa 7cc4f5ab:00000000 00000001 00000000 00000000 000001f7 ffffffff 00007ffa 684431a8:ucrtbase!:: operator()+ 0x65 05 00000090 bc1ffcb0 00007ffa 7cc462ce:00000000 00000001 00000000 00000000 00000000 00000000 00000090 bc1ffd00:ucrtbase!__ crt_seh_guarded_call :: operator()<和__ptr64,> + 0x3b 06 00000090 bc1ffce0 00007ff6 1fd110b0:00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000:ucrtbase!common_exit + 0x5e 07 00000090 bc1ffd30 00007ffa 7d628364:00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000:安装!__ scrt_common_main_seh + 0x16c 08 00000090 bc1ffd70 00007ffa 7fa0e851:00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000:kernel32!BaseThreadInitThunk + 0x14 09 00000090 bc1ffda0 00000000 00000000:00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000:ntdll!RtlUserThreadStart + 0x21

仅使用此静态变量的代码:

```TotalUpdCount(list<wchar_t *> &lvUpdates)
{    
list<wchar_t *>::iterator svListIter;
map<wstring,int>::iterator svVecIter;
static map<wstring,int> svUpdates;
static bool svFirst=true;

if(svFirst)
{
    svUpdates.clear();
    svFirstTime=false;
}
for (svListIter = lvUpdates.begin();
    svListIter != lvUpdates.end();
    svListIter++)
{
    wstring svTmpUpdate=*svListIter;
    svVecIter = svUpdates.find(svTmpUpdate);
    if (svVecIter == svUpdates.end())
        svUpdates.insert(make_pair(svTmpUpdate, 1));
}
nvTotalUpdatesCnt = static_cast<int>(svUpdates.size());


0 个答案:

没有答案