是否为“EXC_BREAKPOINT(SIGTRAP)”调试断点导致异常? [英] Are "EXC_BREAKPOINT (SIGTRAP)" exceptions caused by debugging breakpoints?

查看:544
本文介绍了是否为“EXC_BREAKPOINT(SIGTRAP)”调试断点导致异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多线程应用程序,在我所有的测试机器上都非常稳定,对于几乎每一个用户来说都是稳定的(基于没有任何崩溃的投诉)。尽管如此,一个用户的应用程序频繁崩溃,谁能够发送崩溃报告。所有的崩溃报告(〜10连续报告)看起来基本相同:

 日期/时间:2010-04-06 11:44 :56.106 -0700 
操作系统版本:Mac OS X 10.6.3(10D573)
报告版本:6

异常类型:EXC_BREAKPOINT(SIGTRAP)
异常代码: 0x0000000000000002,0x0000000000000000
崩溃线程:0调度队列:com.apple.main-thread

线程0崩溃:调度队列:com.apple.main-thread
0 com。 apple.CoreFoundation 0x90ab98d4 __CFBasicHashRehash + 3348
1 com.apple.CoreFoundation 0x90adf610 CFBasicHashRemoveValue + 1264
2 com.apple.CoreText 0x94e0069c TCFMutableSet :: Intersect(__ CFSet const *)const + 126
3 com .apple.CoreText 0x94dfe465 TDescriptorSource :: CopyMandatoryMatchableRequest(__ CFDictionary const *,__CFSet const *)+ 115
4 com.apple.CoreText 0x94dfdda6 TDescriptorSource :: CopyDescriptorsForRequest(__ CFDictionary const *,__ CFSet const *,long(*)(void const *,void const *,void *),void *,unsigned long)const + 40
5 com.apple.CoreText 0x94e00377 TDescriptor :: CreateMatchingDescriptors(__ CFSet const * unsigned long)const + 135
6 com.apple.AppKit 0x961f5952 __NSFontFactoryWithName + 904
7 com.apple.AppKit 0x961f54f0 + [NSFont fontWithName:size:] + 39

(....更多文字)



首先,我花了很长时间时间调查[NSFont fontWithName:size:]。我想,也许用户的字体被搞砸了,所以[NSFont fontWithName:size:]正在请求一些不存在和失败的原因。我使用[[NSFontManager sharedFontManager] availableFontNamesWithTraits:NSItalicFontMask]添加了一堆代码,以提前检查字体的可用性。不幸的是,这些变化并没有解决问题。



我现在注意到我忘了删除一些调试断点,包括_NSLockError,[NSException raise]和objc_exception_throw 。但是,应用程序绝对是使用Release作为活动构建配置构建的。我假设使用Release配置可以防止设置任何断点 - 但是我不知道断点是如何工作的,或者程序是否需要从gdb中运行以获得断点才能有任何影响。



我的问题是:我已经离开了断点设置是用户观察到的崩溃的原因吗?如果是这样,为什么断点只会对这个用户造成问题?如果没有,还有其他人也有类似的问题[NSFont fontWithName:size:]?



我可能会尝试删除断点并发回给用户,但我我不知道该用户剩下多少货币。而且我想更了解一下是否设置断点可能会导致问题(应用程序使用Release配置构建时)。

解决方案


是否由调试断点导致EXC_BREAKPOINT(SIGTRAP)异常?


没有。其他方式实际上是:一个SIGTRAP(trace trap)会导致调试器中断你的程序,就像一个实际的断点一样。但是这是因为调试器总是在崩溃中崩溃,而SIGTRAP(像其他一些信号)是一种崩溃类型。



SIGTRAP通常是由抛出的NSExceptions造成的,但并不总是甚至可以直接 raise 我现在已经注意到,我忘了删除一些调试断点,包括_NSLockError,[NSException raise]和objc_exception_throw。


这些不是断点。其中两个是函数, - [NSException raise] 是一种方法。



你的意思是设置断点< em 这些功能和方法?


我假设使用Release配置可以防止设置任何断点 - -


否。



配置是 em>配置。它们会影响Xcode如何构建应用程序。



断点不是构建的一部分;您将它们设置在调试器中。它们只存在,只能受到打击,并且只能在调试器下运行程序时停止程序。



由于它们不是构建的一部分,所以不可能将您的断点传递给用户,只需向他们发送应用程序包。


我不确定断点如何工作...


当您的程序遇到断点时,调试器会中断您的程序,从而可以检查程序的状态,并仔细转发以了解如何程序出错。



由于调试器停止了程序,所以当您没有在调试器下运行程序时,断点无效。


...或者该程序是否需要从gdb内部为断点运行以产生任何影响。


它是。调试器断点只能在调试器中工作。


我的问题是:我已经离开了断点,可能是由于用户?


否。



首先,如所指出的,即使这些断点以某种方式被转移到用户的系统中,断点仅在调试器中有效。如果您的程序未在调试器下运行,则调试器无法在断点上停止。用户几乎肯定不会在调试器下运行您的应用程序,特别是因为它们有一个崩溃登录。



即使他们在调试器下运行您的应用程序当所有这些断点设置时,只有当您的程序达到此点时,断点才会触发,因此,如果您或Cocoa调用 _NSLockError - [NSException raise] objc_exception_throw 。到这一点不会是问题的原因,这将是问题的症状。



如果你因为某个那些被叫的,你的崩溃日志中至少有一个命名为它。它不是。



所以,这与你的断点(不同的机器,调试器没有涉及)无关,而不是Cocoa异常,因为我提到,可可例外是SIGTRAP的一个原因,但它们不是唯一的。你遇到另外一个。


如果没有,还有其他人有类似的问题[NSFont fontWithName:size:]?


我们无法确定是否有任何问题,因为您中断了崩溃日志。我们不知道崩溃发生了什么情况。



唯一可以删除的是二进制图像部分,因为我们没有你的dSYM捆绑,这意味着我们不能使用该部分来表示崩溃日志。



另一方面,您可以。为此写了一个应用程序;将崩溃日志提供给它,并且它应该自动检测dSYM软件包(您为所发布的每个版本版本保留dSYM软件包),并将功能和方法名称还原到堆栈跟踪中,无论您的功能和方法出现在哪里。



有关更多信息,请参阅 Xcode调试指南


I have a multithreaded app that is very stable on all my test machines and seems to be stable for almost every one of my users (based on no complaints of crashes). The app crashes frequently for one user, though, who was kind enough to send crash reports. All the crash reports (~10 consecutive reports) look essentially identical:

Date/Time:       2010-04-06 11:44:56.106 -0700
OS Version:      Mac OS X 10.6.3 (10D573)
Report Version:  6

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   com.apple.CoreFoundation        0x90ab98d4 __CFBasicHashRehash + 3348
1   com.apple.CoreFoundation        0x90adf610 CFBasicHashRemoveValue + 1264
2   com.apple.CoreText              0x94e0069c TCFMutableSet::Intersect(__CFSet const*) const + 126
3   com.apple.CoreText              0x94dfe465 TDescriptorSource::CopyMandatoryMatchableRequest(__CFDictionary const*, __CFSet const*) + 115
4   com.apple.CoreText              0x94dfdda6 TDescriptorSource::CopyDescriptorsForRequest(__CFDictionary const*, __CFSet const*, long (*)(void const*, void const*, void*), void*, unsigned long) const + 40
5   com.apple.CoreText              0x94e00377 TDescriptor::CreateMatchingDescriptors(__CFSet const*, unsigned long) const + 135
6   com.apple.AppKit                0x961f5952 __NSFontFactoryWithName + 904
7   com.apple.AppKit                0x961f54f0 +[NSFont fontWithName:size:] + 39

(....more text follows)

First, I spent a long time investigating [NSFont fontWithName:size:]. I figured that maybe the user's fonts were screwed up somehow, so that [NSFont fontWithName:size:] was requesting something non-existent and failing for that reason. I added a bunch of code using [[NSFontManager sharedFontManager] availableFontNamesWithTraits:NSItalicFontMask] to check for font availability in advance. Sadly, these changes didn't fix the problem.

I've now noticed that I forgot to remove some debugging breakpoints, including _NSLockError, [NSException raise], and objc_exception_throw. However, the app was definitely built using "Release" as the active build configuration. I assume that using the "Release" configuration prevents setting of any breakpoints--but then again I am not sure exactly how breakpoints work or whether the program needs to be run from within gdb for breakpoints to have any effect.

My questions are: could my having left the breakpoints set be the cause of the crashes observed by the user? If so, why would the breakpoints cause a problem only for this one user? If not, has anybody else had similar problems with [NSFont fontWithName:size:]?

I will probably just try removing the breakpoints and sending back to the user, but I'm not sure how much currency I have left with that user. And I'd like to understand more generally whether leaving the breakpoints set could possibly cause a problem (when the app is built using "Release" configuration).

解决方案

Are "EXC_BREAKPOINT (SIGTRAP)" exceptions caused by debugging breakpoints?

No. Other way around, actually: A SIGTRAP (trace trap) will cause the debugger to break (interrupt) your program, the same way an actual breakpoint would. But that's because the debugger always breaks on a crash, and a SIGTRAP (like several other signals) is one type of crash.

SIGTRAPs are generally caused by NSExceptions being thrown, but not always—it's even possible to directly raise one yourself.

I've now noticed that I forgot to remove some debugging breakpoints, including _NSLockError, [NSException raise], and objc_exception_throw.

Those are not breakpoints. Two of them are functions and -[NSException raise] is a method.

Did you mean you set breakpoints on those functions and that method?

I assume that using the "Release" configuration prevents setting of any breakpoints--

No.

The configurations are build configurations. They affect how Xcode builds your applications.

Breakpoints are not part of the build; you set them in the debugger. They only exist, only get hit, and only stop your program when you run your program under the debugger.

Since they aren't part of the build, it's not possible to pass your breakpoints to a user simply by giving them the app bundle.

I am not sure exactly how breakpoints work …

When your program hits the breakpoint, the debugger breaks (interrupts) your program, whereupon you can examine the program's state and step carefully forward to see how the program goes wrong.

Since it's the debugger that stops your program, breakpoints have no effect when you're not running your program under the debugger.

… or whether the program needs to be run from within gdb for breakpoints to have any effect.

It does. Debugger breakpoints only work within the debugger.

My questions are: could my having left the breakpoints set be the cause of the crashes observed by the user?

No.

First, as noted, even if these breakpoints did somehow get carried over to the user's system, breakpoints are only effective in the debugger. The debugger can't stop on a breakpoint if your program isn't running under the debugger. The user almost certainly isn't running your app under the debugger, especially since they got a crash log out of it.

Even if they did run your app under the debugger with all of these breakpoints set, a breakpoint is only hit when your program reaches that point, so one of these breakpoints could only fire if you or Cocoa called _NSLockError, -[NSException raise], or objc_exception_throw. Getting to that point wouldn't be the cause of the problem, it'd be a symptom of the problem.

And if you did crash as a result of one of those being called, your crash log would have at least one of them named in it. It doesn't.

So, this wasn't related to your breakpoints (different machine, debugger not involved), and it wasn't a Cocoa exception—as I mentioned, Cocoa exceptions are one cause of SIGTRAPs, but they are not the only one. You encountered a different one.

If not, has anybody else had similar problems with [NSFont fontWithName:size:]?

There's no way we can tell whether any problems we've had are similar because you cut off the crash log. We know nothing about what context the crash happened in.

The only thing that's good to cut out is the "Binary images" section, since we don't have your dSYM bundles, which means we can't use that section to symbolicate the crash log.

You, on the other hand, can. I wrote an app for this purpose; feed the crash log to it, and it should detect the dSYM bundle automatically (you are keeping the dSYM bundle for every Release build you distribute, right?) and restore your function and method names into the stack trace wherever your functions and methods appear.

For further information, see the Xcode Debugging Guide.

这篇关于是否为“EXC_BREAKPOINT(SIGTRAP)”调试断点导致异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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