sigabrt 没有错误消息
我有一个奇怪的问题,我在主循环中收到 Sigabrt,但没有显示错误消息,我在互联网上对此进行了很多查找,但没有找到任何有用的东西。所以我的问题是,如何在没有错误消息的情况下跟踪导致 sigabrt 的原因?
提前致谢。
I have a strange problem, i am getting a Sigabrt in main loop, but no error message is displayed, i've looked quite a lot on this in the internet but didn't manage to find anything useful. So my question would be, how to track what is causing sigabrt with no error message?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
当您的程序崩溃时,您可以转到调试器控制台并输入
bt
(回溯),这将使您了解崩溃时正在执行哪些代码。顶层项目可能不是您的代码,但如果您继续向下移动,您最终应该会在那里看到您的代码。如果您的代码中没有任何调用,那么这些 SIGABRT 错误通常与您的 xib 文件有关,xib 文件中可能会丢失或重命名或以其他方式更改某些内容,而这些内容尚未反映在您的代码中。
When your program crashes, you can go to the debugger console and type
bt
(backtrace) which will give you an idea of what code was being executed at the time of the crash. The top level items may not be your code, but if you keep moving down you should see something of yours in there eventually.If there aren't any calls from your code then these SIGABRT errors are often related to your xib files, there will be something missing or renamed or otherwise changed in a xib file that hasn't been reflected in your code.
很长一段时间以来,我一直以为控制台没有向我提供 XCode 8 的任何信息,但后来我意识到我只是隐藏了控制台,需要再次显示它。
对于像我一样陷入奇怪的大脑扭曲的任何人:
按那个按钮,看看 XCode 告诉你什么坏了,修复它
再次享受生活!
For way too long, I thought the console was giving me no information with XCode 8 but then I realized I just had hidden the console and needed to show it again.
For anyone else stuck in a weird brain warp like I was:
Press that button and see what XCode is telling you is broken, fix it
Enjoy life again!
你看过日志吗?
您是否尝试过在调试器中运行?它应该停止并给你一个堆栈跟踪。还可以尝试在所有异常上设置断点。
Have you looked in the logs?
Have you tried running in the debugger? It should stop and give you a stack trace when it. Also try setting a break point on all exceptions.
对于 SIGABRT 错误,请在调试中运行,直到程序崩溃。然后,在迷你调试栏中的代码编辑器上方应该有一个黑色小按钮,上面有黄色文本“GDB”。单击它,它将打开您的调试器控制台。这应该显示 sig-abort 报告,可能是一条警报,指出它是由未处理的抛出异常引起的,所有嵌套函数调用的堆栈跟踪,以及处理具体错误的一条或多条消息。
我不知道实际的启动错误出了什么问题,但很可能您更改了代码中由 xib 文件引用的某些类的名称,并且没有更改 Interface Builder 中的引用。
仅当应用程序调用资源中缺少的内容时才会出现此错误。
例如,我有一个(IBAction)可以播放声音,但声音不再是应用程序的一部分。
检查代码中所有调用的资源,并确保它们仍在您的 xcode 项目中。甚至 Interface builder 中使用的图像也可以生成 SIGARBT。
这是一个烦人的错误,因为 9/10 的情况下调试器不会告诉您出了什么问题。
For SIGABRT errors, run in debug until the program crashes. Then, there should be a little black button with the text "GDB" in yellow over it above your code editor in your mini-debugging bar. Click it, and it will bring up your debugger console. This should show the sig-abort report, possibly an alert stating that it was caused by an unhandled thrown exception, the stack trace of all nested function calls, and above that, one or more messages dealing with what specifically went wrong.
I don't know what is wrong with the actual startup error, but it could be very likely you changed the name of some class in your code that was referenced by your xib files, and didn't change the references in Interface Builder.
only ever get this error when the app is calling on something that is missing from resources.
e.g I have an (IBAction) which plays a sound but the sound is no longer part of the app.
Check all of your called resources in your code and make sure they're still in your xcode project. Even images used in Interface builder can produce a SIGARBT.
It's an annoying error because 9/10 times the debugger doesn't tell you what's wrong.
就我而言,我没有正确处理异步调用和多线程,并且在没有任何消息的情况下发生了
SIGABRT
崩溃。在这种情况下确实很难调试,但一般提示是使用回调来处理一系列操作。不要同时运行太多操作,即使它们彼此无关。
In my case, I didn't handle asynchronous calls and multi-threading properly, and I got a
SIGABRT
crash without any messages.It's really hard to debug in this situation, but a general hint is using callbacks to handle your series of actions. Don't run too many actions at the same time even they are irrelevant to each other.
就我而言,问题是在视图被驳回后没有被删除的观察者。具体来说是 Google 地图中@“myLocation”的观察者。
所以我在 viewDidLoad 上有这个:
但我从未删除它,并且在关闭地图视图时我会不断崩溃我的应用程序。
我添加了这个:
问题解决了。
In my case, the problem was an observer that wasn't being removed after a view got dismissed. Specifically an observer on the @"myLocation" in Google Maps.
So I have this on viewDidLoad:
But I never removed that and I would constantly crash my app when dismissing the map view.
I added this:
And problem solved.