iPhone应用程序崩溃,不会留下.crash日志文件 [英] iPhone application is crashing and not leaving behind a .crash log file

查看:263
本文介绍了iPhone应用程序崩溃,不会留下.crash日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个严重的潜在错误,在我的代码。问题是,该bug是完全随机的,可以发生在9分钟到应用程序的运行时或30分钟。我已经将我的项目( http://code.google.com/)添加了神话般的PLCrashReporter p / plcrashreporter ),并适用于微小的bug。此外,当我有疑问,我将导航到崩溃日志中找到〜/ Library / Logs / CrashReporter / MobileDevice /和运行symboliccrash崩溃日志。这+ GDB最终会捕获任何错误,除了我现在面临的一个。



显然,这个bug的本质是防止苹果的崩溃日志被正确写入存储。这表示当我使用iTunes同步我的iPhone或iPod Touch和在我的应用程序上运行symbolicatecrash:

  sf $ symbolicatecrash foo.crash 
在/ usr / local / bin / symbolicatecrash行741中的foo.crash中没有崩溃报告版本。

这可能是我的应用程序不离开崩溃报告,并退出由于内存问题。我确实看到applicationWillTerminate:在退出之前,在我的App Delegate中执行我的NSLog语句。但是,通过ObjectAlloc运行应用程序后,我的应用程序从未达到> 2.08MB的使用率。虽然如果我正确地读取结果,我在我的测试运行的整个持续时间内分配了超过28MB的内存。



再次感谢一切。

解决方案


  1. 确保你实际上不是调用exit(),从main()返回,你的代码。如果你的应用程序只是退出,而不是崩溃,显然不会留下日志。


  2. 我认为运行系统非常快速的内存不足有时会导致您的应用程序崩溃,而不会留下崩溃日志。


  3. 如果您有一组经常再现问题的步骤,请尝试运行它在调试器下,并戳它,直到它崩溃。


消除了明显的/简单的问题, -朦胧。有可能是你通过缓冲区溢出,重新使用一个无效的指针等等破坏你的堆或堆栈的某处。这里有一些事情要尝试:


  1. 尝试在环境变量中使用NSZombieEnabled = YES运行。这将帮助您找到重新使用释放的对象。它确实对内存使用有巨大的影响,因此它可能不适用于每个人。这是


  2. 在iPhone模拟器中运行时,请使用硬件菜单中的模拟内存警告项目强制低内存条件 - 这可以清除该代码中的错误,否则会在不可预测的时间运行。


  3. p>最后但并非最不重要的是,在你使用低级C内存操作函数(malloc,calloc,realloc,memcpy,strcpy,strncpy等)的任何地方进行搜索,并确保缓冲区大小是合适的。



I'm working on catching a seriously insidious bug that's happening in my code. The problem is, the bug is completely random and can happen either 9 minutes into the application's runtime or 30 minutes. I've gone ahead and added the fabulous PLCrashReporter to my project (http://code.google.com/p/plcrashreporter) and that works fine for trivial bugs. Also, when I'm in doubt, I will navigate to the crash logs found in ~/Library/Logs/CrashReporter/MobileDevice/ and run symbolicatecrash on the crash log. This + GDB will eventually catch any bug, except for the one I'm facing now.

Apparently the nature of this bug is preventing even Apple's crash logs to be properly written to storage. This shows when I sync my iPhone or iPod Touch with iTunes and run symbolicatecrash on my app:

sf$ symbolicatecrash foo.crash 
No crash report version in foo.crash at /usr/local/bin/symbolicatecrash line 741.

It might be that my application is not leaving a crash report at all, and exiting due to memory issues. I do indeed see the applicationWillTerminate: executing my NSLog statement before exiting, in my App Delegate. However, after running the application through ObjectAlloc, my application never reaches > 2.08MB of usage. Although if I'm reading the results proper, I did allocate over 28MB of memory throughout the entire duration of my test run.

Thanks again for everything.

解决方案

A couple of suggestions:

  1. Make sure that you're not actually calling exit(), returning from main(), or otherwise cleanly exiting anywhere in your code. If your application is just quitting, and not crashing, that obviously won't leave a log.

  2. I think that running the system very rapidly out of memory can sometimes cause your application to crash without leaving a crash log. Run it under Instruments and see what the memory usage over time looks like.

  3. If you have a set of steps that "often" reproduces the problem, try running it under the debugger and poking at it until it does crash. That might be a half-hour well-spent.

Having eliminated the obvious/easy, it's on to the more-obscure. Chances are that you're corrupting your heap or stack somewhere along the way, via a buffer overrun, re-using an invalid pointer, etc, etc. Here are some things to try:

  1. Try running with NSZombieEnabled=YES in the environment variables. This will help you find re-use of freed objects. It does have an enormous impact on memory usage though, so it may not be applicable for everyone. Here's an Apple article dealing with NSZombie (among other things).

  2. When running in the iPhone Simulator, use the "Simulate Memory Warning" item in the Hardware menu to force a low-memory condition - this can flush out bugs in that code, which otherwise runs at unpredictable times.

  3. Last but not least, do a search through your code for everywhere that you use low-level C memory manipulation functions - malloc, calloc, realloc, memcpy, strcpy,strncpy, etc - and make absolutely sure that the buffer sizes are appropriate.

这篇关于iPhone应用程序崩溃,不会留下.crash日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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