【发布时间】:2012-11-14 10:16:14
【问题描述】:
该库正在使用 std::string。当某些特定的应用程序与它链接时,在库中执行的字符串操作变得完全崩溃。
例如字符串赋值运算符'='(附加堆栈跟踪)。
memcpy_s( ... ) 的目的地和大小看起来很混乱。
我们无法在本地复制它。请指教。
编辑: 代码如下所示:
...
#define DEFAULT_VAL "value"
...
class MyClass {
public:
MyClass(const std::string& s=DEFAULT_VAL)
{
_test() = s;
}
protected:
inline const std::string& test() const {return m_test;}
inline std::string& _test() {return m_test;}
private:
std::string m_test;
};
....
MyClass c;
【问题讨论】:
-
这看起来像是由于访问越界、堆栈损坏、释放后访问、双重释放等导致的内存损坏。
valgrind(或类似工具)是你的朋友。 -
0xCD 是 Microsoft 调试堆中的干净内存填充器。所以我的猜测是您的应用程序在某处使用了未初始化的对象。
-
共享显示错误的代码块可能有助于调试。只是说'
-
为什么要在客户站点运行调试版本?
标签: c++ dll crash std stdstring