调用 new 关键字 C++ 时,Glibc 检测到 malloc() 内存损坏 (0xb6179bb8)

发布于 2024-09-25 07:59:27 字数 186 浏览 3 评论 0原文

我的程序运行到调用 new 关键字会导致上述错误的程度。即char* a = new char[100]。该错误每次都是可重现的。我运行该程序直到调用 new 关键字。似乎内存位置此时已损坏,但我不确定他的问题是什么。

导致此错误的可能原因有哪些?

My program runs to a point where calling the new keyword would cause the error stated above. i.e. char* a = new char[100]. The error is reproducible and every time. I run the program until that point of calling the new keyword. It seems to be the memory location is corrupted at the point, but I'm not sure what he issue is.

What are the possible causes for this error?

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

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

发布评论

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

评论(1

错爱 2024-10-02 07:59:27

此错误意味着您已损坏系统内存管理器的簿记数据。
此类损坏通常是由于不正确使用指针造成的,例如

  • 使用未初始化的指针
  • 在释放其引用的内存后使用指针(释放可能是通过另一个指针发生的)
  • 在数组边界之外写入

This error means that you have corrupted the bookkeeping data of the system memory manager.
Such corruptions are typically the result of incorrect use of pointers, such as

  • Using an uninitialised pointer
  • Using a pointer after the memory it refers to has been freed (the freeing could have happened through another pointer)
  • Writing outside your array bounds
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文