如何找到malloc“双倍自由”的原因错误? [英] How to find the cause of a malloc "double free" error?

查看:166
本文介绍了如何找到malloc“双倍自由”的原因错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Objective-C编写应用程序,我收到此错误:

I'm programming an application in Objective-C and I'm getting this error:


MyApp(2121,0xb0185000)malloc :* **对象0x1068310的错误:双免费

***在malloc_error_break中设置断点以进行调试

MyApp(2121,0xb0185000) malloc: *** error for object 0x1068310: double free
*** set a breakpoint in malloc_error_break to debug



<当我发布一个NSAutoreleasePool并且我无法弄清楚我要发布两次的对象时,就会发生这种情况。

It is happening when I release an NSAutoreleasePool and I can't figure out what object I'm releasing twice.

如何设置断点?

有没有办法知道这个对象0x1068310是什么?

Is there a way to know what is this "object 0x1068310"?

推荐答案

当你在调试器中断时,你会发现对象是什么。只需查看调用堆栈,您就会找到释放它的位置。这将告诉你它是哪个对象。

You'll find out what the object is when you break in the debugger. Just look up the call stack and you will find where you free it. That will tell you which object it is.

设置断点的最简单方法是:

The easiest way to set the breakpoint is to:



  1. 转到运行 - >显示 - >断点( ALT - 命令 - B

  2. 滚动到列表底部并添加符号 malloc_error_break

  1. Go to Run -> Show -> Breakpoints (ALT-Command-B)
  2. Scroll to the bottom of the list and add the symbol malloc_error_break


这篇关于如何找到malloc“双倍自由”的原因错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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