_DebugHeapDelete 终止时访问冲突 [英] _DebugHeapDelete Access Violation at termination

查看:31
本文介绍了_DebugHeapDelete 终止时访问冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主程序末尾遇到了一个奇怪的访问冲突,我很难找到其原因.

I'm getting a weird access violation at the end of my main whose cause I'm having some difficulties finding.

在关闭我的应用程序时,我收到以下访问冲突:

When shutting down my application I get an access violation in the following:

调试

        // TEMPLATE FUNCTION _DebugHeapDelete
template<class _Ty>
    void __CLRCALL_OR_CDECL _DebugHeapDelete(_Ty *_Ptr)
    {   // delete from the debug CRT heap even if operator delete exists
    if (_Ptr != 0)
        {   // worth deleting
        _Ptr->~_Ty();
        // delete as _NORMAL_BLOCK, not _CRT_BLOCK, since we might have
        // facets allocated by normal new.
        free(_Ptr); // **ACCESS VIOLATION**
        }
    }

堆栈跟踪:

>   msvcp100d.dll!std::_DebugHeapDelete<void>(void * _Ptr)  Line 62 + 0xa bytes C++
    msvcp100d.dll!std::numpunct<char>::_Tidy()  Line 190 + 0xc bytes    C++
    msvcp100d.dll!std::numpunct<char>::~numpunct<char>()  Line 122  C++
    msvcp100d.dll!std::numpunct<char>::`scalar deleting destructor'()  + 0x11 bytes C++
    msvcp100d.dll!std::_DebugHeapDelete<std::locale::facet>(std::locale::facet * _Ptr)  Line 62 C++
    msvcp100d.dll!std::_Fac_node::~_Fac_node()  Line 23 + 0x11 bytes    C++
    msvcp100d.dll!std::_Fac_node::`scalar deleting destructor'()  + 0x11 bytes  C++
    msvcp100d.dll!std::_DebugHeapDelete<std::_Fac_node>(std::_Fac_node * _Ptr)  Line 62 C++
    msvcp100d.dll!_Fac_tidy()  Line 41 + 0x9 bytes  C++
    msvcp100d.dll!std::_Fac_tidy_reg_t::~_Fac_tidy_reg_t()  Line 48 + 0xe bytes C++
    msvcp100d.dll!std::`dynamic atexit destructor for '_Fac_tidy_reg''()  + 0xf bytes   C++
    msvcp100d.dll!_CRT_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 415 C
    msvcp100d.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 526 + 0x11 bytes  C
    msvcp100d.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 476 + 0x11 bytes   C

有人对可能导致这种情况的原因有任何想法吗?

Anyone got any ideas as to what might cause this?

我读了一些关于被缓存的方面的内容,不确定这是否相关?

I read something about facets being cached not sure if thats related?

推荐答案

内存损坏错误可以(显然)导致这种(以及许多其他类型的)失败.

Memory corruption bugs can (obviously) cause this (and many other kinds) of failure.

您是否尝试过使用 valgrind (memcheck) 或 Rational Purify 来解决这个问题?它可能会报告问题(如果这是您第一次对代码库运行此类检查,则可能会被大量其他信息掩盖.您将仍然想设计一个最小的主要"' 表现出在内存和边界检查器下运行的行为的实现

Have you tried using valgrind (memcheck) or Rational Purify against this? It will probably report the problem (possibly buried in a whole lot of other information if this would be the first time you ran such a check on your code base. You will still want to devise a minimal 'main' implementation that exhibits the behaviour to run under a memory and bounds checker

$0.02

附注.以防万一,通常会出现内存损坏错误

PS. just in case, memory corruption bugs usually arise

  • 通过取消引用过时的指针(在释放/删除之后)
  • 写入超出已分配缓冲区的末尾
  • 通过释放/删除以前的指针(主要是所有权跟踪不良的症状)

这篇关于_DebugHeapDelete 终止时访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆