Xcode 4:由于 iPad 模拟器的 dylib 错误,无法使用启用 Guard Malloc

发布于 2024-12-09 16:23:54 字数 823 浏览 5 评论 0原文

在 Xcode 4.x 中,我已将运行方案编辑为“启用 Guard Malloc”,因为我有一个需要追踪的不伦不类的 malloc 错误。我知道我需要在模拟器中运行才能使用此功能。但是,当我这样做时,应用程序立即冻结,并且 Xcode 向我显示如下所示的堆栈跟踪:

Xcode 4 中的堆栈跟踪。 x

我已经用谷歌搜索寻找解决方案,但到目前为止还没有任何乐趣。据其他地方报道,我应该在我的方案中设置一个环境变量:

DYLD_INSERT_LIBRARIES  ->  /usr/lib/libgmalloc.dylib

但这并不能解决问题。我也尝试过将“lsystem”作为值,但这也不起作用。

任何人都可以建议解决此 dylib 问题,或者推荐“启用 Guard Malloc”的替代方案来确定超出 malloc 堆区域的位置?

更新

澄清一下,这是我正在处理的错误类型:

malloc: *** error for object 0x2b4b54: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

我尝试设置 malloc_error_break 的符号断点,但它仍然在内存上“随机”中断问题而不是超出分配的区域。

In Xcode 4.x I've edited my Run scheme to 'Enable Guard Malloc' since I have a nondescript malloc error I need to track down. I'm aware I need to run in the simulator to use this feature. However, when I do so the app immediately freezes and Xcode shows me a stack trace that looks like this:

Stack trace in Xcode 4.x

I've googled around to find a solution, but thus far no joy. It was reported elsewhere that I should be setting an environment variable in my scheme:

DYLD_INSERT_LIBRARIES  ->  /usr/lib/libgmalloc.dylib

However this doesn't solve the problem. I have also tried 'lsystem' as the value, but that didn't work either.

Can anyone suggest a solution to this dylib issue, or perhaps recommend an alternative to 'Enable Guard Malloc' to identify where a malloc'd heap area is being exceeded?

UPDATE

To clarify, this is the type of error I'm dealing with:

malloc: *** error for object 0x2b4b54: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

I've tried setting a symbol breakpoint of malloc_error_break, however it still breaks 'randomly' upon memory issues rather than at the point of exceeding an allocated region.

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

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

发布评论

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

评论(1

掀纱窥君容 2024-12-16 16:23:54

为了帮助调试,您可以设置 MallocStackLogging,然后当您的应用程序崩溃时,输入以下内容gdb 控制台:

(gdb) info malloc-history 0x543216

将 0x543216 替换为导致崩溃的对象的地址,您将获得更有用的堆栈跟踪,它应该可以帮助您查明代码中导致崩溃的确切行导致了问题。

请参阅本文以获取更详细的说明。

To help with the debugging you can set MallocStackLogging, then when your App crashes, type this in the gdb console:

(gdb) info malloc-history 0x543216

Replace 0x543216 with the address of the object that caused the crash, and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.

See this article for more detailed instructions.

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