iOS error : Heap corruption detected, free list is damaged and Incorrect guard value: 0

iOS error : Heap corruption detected, free list is damaged and Incorrect guard value: 0

GFF_MJ(3248,0x103f9ab80) malloc: Heap corruption detected, free list is damaged at 0x28298ffa0
*** Incorrect guard value: 0
GFF_MJ(3248,0x103f9ab80) malloc: *** set a breakpoint in malloc_error_break to debug

错误截图:

运行一段时间后,应用程序总是崩溃,但除了上述提示外,我不会得到任何信息。 现在不知道怎么解决,谁能帮帮我?

谢谢。

这些错误一点都不好玩。最有可能的是,您在某处发生了缓冲区溢出,或者您正在使用一块内存,该内存已被释放并踩到其他东西上。

因为你可以让它在调试器中崩溃,所以更容易追踪。

首先在 malloc_error_break 上设置断点,按照错误消息的指示进行操作。当您遇到该断点时,这将提供更多线索,但仍然可能相当模糊。但是,您将能够 post 更多线索,我们可以从那里帮助您。

就我而言,这是模拟器(内存)的问题。

清理构建文件夹或关闭模拟器后尝试在真实设备中编译它并再次运行。

我在 macOS 上遇到了这个错误。清理构建文件夹解决了这个问题。