在混合模式x64 C ++应用程序中启动时出现堆损坏 [英] Heap corruption at startup in mixed-mode x64 C++ application

查看:52
本文介绍了在混合模式x64 C ++应用程序中启动时出现堆损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个混合模式的C ++应用程序(带有本机库的/ Clr代码),都是用VS 2008编译的。



Win32平台构建工作正常。相反,x64构建在应用程序启动时非常快速崩溃。



经过费力的调试后,我发现在本机库中创建全局范围对象会引发堆损坏断言(在动态初始化器调用时)。



对象构造函数的代码不是原因。


我该怎么办?

I have a mixed-mode C++ application (/Clr code with a native library), all compiled with VS 2008.

The Win32 platform build works fine. On the opposite, the x64 build crashes very quickly at application startup.

After laborious debugging, I observe that the creation of a global-scope object in the native library raises a heap corruption assertion (upon "dynamic initializer" invocation).

The code of the object constructor is not the cause.

What can I do ?

推荐答案

在您找到的代码之前运行的某些代码有可能,甚至可能是造成这个问题。该代码将覆盖堆,然后当代码运行时,由于先前的错误,它会被破坏。
It is possible, perhaps even likely, that some code that runs before the code that you found is what is causing the problem. That code overwrites the heap and then when your code runs it becomes corrupted due to the previous error.


可能是因为我只是通过在函数内部移动全局静态变量声明来解决问题。



这个问题显然已经消失了。希望这不仅仅是因为新的内存布局更好地隐藏了一些不稳定的内存引用...
It might be that I have solved the issue just by moving the global static variable declarations inside functions.

The problem has apparently disappeared. Hope it is not just because the new memory layout better hides some erratic memory reference...


小心系统异常会因莫名其妙的代码更改而消失。



这些类型的代码更改会修改执行路径 - 这本质上可以使系统异常无法显示而无需修复问题。
Be careful of system exceptions that disappear by inexplicable code changes.

Those sorts of code changes modify the execution path - which by its very nature can make the system exception fail to appear WITHOUT fixing the problem.


这篇关于在混合模式x64 C ++应用程序中启动时出现堆损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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