如何查找malloc“double free"的原因错误? [英] How to find the cause of a malloc "double free" error?

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

问题描述

我正在使用 Objective-C 编写应用程序,但出现此错误:

<块引用>

MyApp(2121,0xb0185000) malloc: *** error for object 0x1068310: double free
*** 在 malloc_error_break 中设置断点进行调试

当我释放一个 NSAutoreleasePool 并且我无法弄清楚我释放了两次什么对象时就会发生这种情况.

我如何设置他的断点?

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

解决方案

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

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

<块引用>

  1. 转到运行 -> 显示 -> 断点(ALT-Command-B)
  2. 滚动到列表底部并添加符号 malloc_error_break

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

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

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

How do I set his breakpoint?

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. Go to Run -> Show -> Breakpoints (ALT-Command-B)
  2. Scroll to the bottom of the list and add the symbol malloc_error_break

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

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