unique_ptr 删除程序导致我的程序崩溃

发布于 2024-12-09 23:17:58 字数 287 浏览 1 评论 0原文

在运行时,当我关闭程序时,我收到错误:“crt 检测到应用程序在堆缓冲区结束后写入内存。”我通过析构函数跟踪程序执行到唯一 ptr 的删除器,并且在调用删除器函数时发生错误。我想提到的另一个问题是,由于某种原因,唯一 ptr 所在的类定义要求它有一个公共复制构造函数。我尝试在另一个具有不同类和相同类的项目中复制这些问题,删除复制构造函数和析构函数并更改访问标签。我无法复制相同的问题 - 这两个项目之间最大的区别是有问题的一个是共享库,这可能是问题所在吗?必须定义复制构造函数,虽然烦人且多余,但我并不太关心,任何有关此内存错误的猜测或建议都将受到高度赞赏。

At run time when I close my program I get the error: "crt detected that the application wrote to memory after end of heap buffer." I followed the program execution through a destructor to the deleter of the unique ptr and the error occured on the call to the deleter function. Another problem I want to mention is that for some reason the class defenition that the unique ptr is in requires that it has a public copy constructor. I tried to replicate these problems in another project with a different class and the same one, removing the copy constructor and destructor and changing the access labes. I couldn't replicate the same problems - the biggest difference between these two projects is the one with problems is a shared library, could this be the problem? Having to define the copy constructor although annoying and redundant I dont really care to much about, any speculations or advice on this memory error would be highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌伤ぢ 2024-12-16 23:17:58

crt 检测到应用程序在堆缓冲区末尾后写入内存。

是的,当您调用删除时,会出现此消息,但它表示发现一个错误。没有造成一。在代码中的某个位置,您正在写入超出数组末尾的内容,然后在删除过程中,内存管理器在越界区域中发现了“足迹”。

在每次访问数组之前,输入:

assert(index<array_size);

crt detected that the application wrote to memory after end of heap buffer.

Yes, this message appears when you call delete, but it's saying it found an error. Not caused one. Somewhere in your code, you are writing past the end of an array, and then during the delete, the memory manager found "footprints" in an out-of-bounds area.

Before each and every array access, put in :

assert(index<array_size);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文