Xcode 4: Can't use Enable Guard Malloc due to dylib error for iPad simulator

喜欢而已 提交于 2019-12-20 14:23:40

问题


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:

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.


回答1:


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.



来源:https://stackoverflow.com/questions/7764268/xcode-4-cant-use-enable-guard-malloc-due-to-dylib-error-for-ipad-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!