_DebugHeapDelete Access Violation at termination

后端 未结 4 1578
青春惊慌失措
青春惊慌失措 2021-01-23 00:40

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 violatio

4条回答
  •  太阳男子
    2021-01-23 01:29

    The first, accepted, response is correct, but it does not show exactly the reason and hence the way of fixing it. According to the listed part of the call stack, I've encountered into the same problem with VC++8 (MS VS 2005) but in the different case: my CLR DLL caused AV at the same point of the code.

    From the listed call stack it is seen that the code of that is normally compiled into msvc*.dll is called but at that moment the _Ptr already has wrong value. Hence, there is some code that either already freed the object under this pointer or set an exit hook to free the uninitialized object.

    If _STATIC_CPPLIB was defined, the code could be complied into other modules that are loaded into the application process. Then, one exit procedure of those modules could be called prior to another one in msvcp100d.dll and thus could normally free the facet object. In my case, with _STATIC_CPPLIB defined, both the modules (exe and clr dll) were compiled.

    Solution for VC++8,9

    Check the final compiler options in the "Command Line" section for the presence /D "_STATIC_CPPLIB". Undefining _STATIC_CPPLIB and recompiling affected modules fixes the AV at program termination.

    Note on _STATIC_CPPLIB

    For VC++9 _STATIC_CPPLIB, at MSDN, there is the note that

    the combination of the _STATIC_CPPLIB preprocessor definition and the /clr or /clr:pure compiler option is not supported.

    And there are no mentions on _STATIC_CPPLIB for higher VS versions. For higher VS versions and VS 10 in particular, I suppose that the code dependent on _STATIC_CPPLIB still exists. In the TS's case, if _STATIC_CPPLIB is still used in the compiler options of any TU that includes or other headers including , this improper combination could lead to AV.

提交回复
热议问题