异常代码的含义是EXC_I386_GPFLT什么?
其含义是否因情况而异?
在这种情况下,我指的是EXC_BAD_ACCESS带有异常代码的异常类型EXC_I386_GPFLT
该程序是在Xcode 5.0.1中开发的,处理cblas_zgemm()BLAS库.(好吧,我想这没关系......)
非常感谢你!
A UIViewController将自己添加到默认中心:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(editFood)
name:@"editFood"
object:nil];
Run Code Online (Sandbox Code Playgroud)
然后UITableView代表NSObject发布一个NSNotification:
[[NSNotificationCenter defaultCenter]
postNotificationName:@"editFood"
object:self];
Run Code Online (Sandbox Code Playgroud)
在运行时,它会获得EXC_BAD_ACCESS异常.
是在defaultCenter哪里获得释放?当我从UIViewController向UIViewController发布通知时,同样的概念也有效,但这不重要,对吧?
我是iPhone开发和XCode的新手,并不知道如何开始对EXC_BAD_ACCESS信号进行故障排除.如何让XCode在导致错误的确切行中断?
我似乎无法让XCode停在线路上导致问题,但我确实在调试控制台中看到以下几行:
Sun Oct 25 15:12:14 jasonsmacbook TestProject [1289]:CGContextSetStrokeColorWithColor:无效的上下文
Sun Oct 25 15:12:14 jasonsmacbook TestProject [1289]:CGContextSetLineWidth:无效的上下文
Sun Oct 25 15:12:14 jasonsmacbook TestProject [1289]:CGContextAddPath:无效的上下文
Sun Oct 25 15:12:14 jasonsmacbook TestProject [1289]:CGContextDrawPath:无效的上下文
2009-10-25 15:12:14.680 LanderTest [1289:207]*** - [CFArray objectAtIndex:]:消息发送到释放的实例0x3c4e610
现在,我试图绘制到我检索的上下文UIGraphicsGetCurrentContext()并传递给我想要绘制的对象.
进一步的试验和错误调试,我发现NSMutableArray我的班上有一个属性是一个僵尸.我进入了init该类的函数,这是我使用的代码:
if ((self = [super init])) {
NSMutableArray *array = [NSMutableArray array];
self.terrainBlocks = array;
[array release];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
我删除了[array release]线,它不再给我EXC_BAD_ACCESS信号,但我现在很困惑为什么这个工作.我认为当我使用该属性时,它会自动为我保留它,因此我应该从内部释放它init以便我没有泄漏.我完全混淆了它是如何工作的,我读过的所有指南和Stackoverflow问题只会让我更加困惑如何在我的init方法中设置属性.关于哪种方式最好,似乎没有达成共识.
我想弄清楚为什么我在我的应用程序中遇到此崩溃.
它在使用ios5.1的模拟器中运行的Xcode 4.4中运行得非常好,但是当我切换到xcode 4.5和ios6时,我得到一个EXC_BAD_ACCESS代码2.这是我的代码:
- (void) myMethod
{
UIAlertView *alertview = [[[UIAlertView alloc]initWithTitle:@"Title" message:@"message" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil] autorelease];
alertview.tag = 1
[alertview show];
}
Run Code Online (Sandbox Code Playgroud)
这是给我一个EXC_BAD_ACCESS码2上[UIAlertView show]线
有任何想法吗?
谢谢!
我有一个iPhone SDK应用程序,有多个视图在用户创建内容时出现和消失.在设备上使用该应用程序一段时间后,我遇到以下崩溃:
Program received signal: “EXC_BAD_ACCESS”.
(gdb) backtrace
#0 0x33369ebc in objc_msgSend ()
#1 0x320e5248 in -[UIScrollView(UIScrollViewInternal) _scrollViewAnimationEnded] ()
#2 0x338b4a14 in -[NSObject performSelector:withObject:] ()
#3 0x320e5098 in -[UIAnimator stopAnimation:] ()
#4 0x320e4b7c in -[UIAnimator(Static) _advance:] ()
#5 0x320e4a34 in LCDHeartbeatCallback ()
#6 0x34350e60 in HeartbeatVBLCallback ()
#7 0x332e91c0 in IOMobileFramebufferNotifyFunc ()
#8 0x316532f8 in ?? ()
#9 0x33866b50 in __CFMachPortPerform ()
#10 0x338ae52a in CFRunLoopRunSpecific ()
#11 0x338adc1e in CFRunLoopRunInMode ()
#12 0x3434e1c8 in GSEventRunModal ()
#13 0x32002c30 in …Run Code Online (Sandbox Code Playgroud) 我试图在UICollectionView中实现一个搜索栏作为UICollectionViewReusableView
这样我就不使用UISearchController但是我正在更改collectionview的数据源
在我的自定义布局中,我以这种方式添加搜索栏:
override func prepareLayout() {
super.prepareLayout()
var searchBarAttributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: TeacherSearchbarIdentifier, withIndexPath: NSIndexPath(forItem: 0, inSection: 0))
searchBarAttributes.frame = CGRectMake(0, 0, collectionViewContentSize().width, 44)
searchBarAttributes.zIndex = 100
miscAttributes.append(searchBarAttributes)
}
override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? {
var attributes = [UICollectionViewLayoutAttributes]()
for (idx, attr) in enumerate(miscAttributes) {
if CGRectIntersection(rect, attr.frame) != CGRectNull {
attributes.append(attr)
}
}
return attributes
}
Run Code Online (Sandbox Code Playgroud)
我正在设置这样的委托:
func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
var view = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: kind, forIndexPath: indexPath) as! …Run Code Online (Sandbox Code Playgroud) 我注意到实现NSURLSessionDataDelegate和启动任务偶尔会抛出一个EXC_BAD_ACCESS.给出错误的实际调用方法似乎有所不同,但总是来自CFNetwork.在大多数情况下,调用方法来自NSURLSession delegate_dataTask:didReceiveData:completionHandler.我在下面附上了两个不同来电的崩溃日志.我还附上了我的实施NSURLSessionDataDelegate.
不幸的是我无法可靠地重现错误,所以我没有一个示例脚本来共享.创建和启动Downloader对象最终会产生错误.对于较大的文件,它似乎经常发生.我在这里做错了吗?有没有一种好的方法从这个堆栈跟踪调试?
我已经在iOS10和10.1.1上测试了相同的结果.
执行:
class Downloader: NSObject, NSURLSessionDataDelegate {
private let url: String
var finished = false
let finishCondition = NSCondition()
init(url:String) {
self.url = url
super.init()
}
func start() {
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config,
delegate: self,
delegateQueue: nil)
guard let u = NSURL(string: url) else {
return
}
let request = NSMutableURLRequest(URL: u)
let task = session.dataTaskWithRequest(request)
task.resume()
}
func URLSession(session: NSURLSession, dataTask: …Run Code Online (Sandbox Code Playgroud) 我遇到了使用UIWebView的应用程序崩溃.通常是在页面没有完全加载并且UIWebView被发送到stopLoading选择器时.或者当UIWebView完全加载页面时.我有EXC_BAD_ACCESS.堆栈看起来像这样:
#0 0x95bb7688 in objc_msgSend
#1 0x30a671db in -[UIWebView webView:decidePolicyForNavigationAction:request:frame:decisionListener:]
#2 0x3024a10d in __invoking___
#3 0x30249ff8 in -[NSInvocation invoke]
#4 0x358ab160 in HandleDelegateSource
#5 0x302452c1 in CFRunLoopRunSpecific
#6 0x30244628 in CFRunLoopRunInMode
#7 0x32044c31 in GSEventRunModal
#8 0x32044cf6 in GSEventRun
#9 0x309021ee in UIApplicationMain
#10 0x0000239c in main at main.m:13
Run Code Online (Sandbox Code Playgroud)
对我来说,最奇怪的是这里是webView:decidePolicyForNavigationAction:request:frame:decisionListener:选择器发送到UIWebView,因为在UIWebView文档中没有这样的选择器!仅适用于Cocoa(不是可可触摸)WebView.我怀疑UIWebView或其委托有问题.但我无法设置断点来观察它们.请告知我如何在这种情况下获得更多信息.
我在UICollectionView中遇到了一个奇怪的崩溃.崩溃的UICollectionView嵌入在另一个UICollectionView的UICollectionView单元格中.
我无法重现这个问题,有时如果内部UICollectionView得到新的初始化,因为外部CollectionView正在重新加载它的单元格.
com.apple.main-thread Crashed 0 libobjc.A.dylib objc_msgSend + 9 1 UIKit -[UICollectionViewData _setLayoutAttributes:atGlobalItemIndex:] + 60 2 UIKit __45-[UICollectionViewData validateLayoutInRect:]_block_invoke_0 + 668 3 UIKit -[UICollectionViewData validateLayoutInRect:] + 1408 4 UIKit -[UICollectionViewData layoutAttributesForElementsInRect:] + 82 5 UIKit -[UICollectionView setCollectionViewLayout:animated:] + 1644 6 MyApp BSCTopnewsCollectionView.m line 52 -[BSCTopnewsCollectionView setupBSCTopnewsCollectionView] 7 MyApp BSCTopnewsCollectionView.m line 27 -[BSCTopnewsCollectionView setWeakDelegatePointer:] 8 Myapp BSCFrontPageViewController.m line 550 -[BSCFrontPageViewController collectionView:cellForItemAtIndexPath:] 9 UIKit -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:] + 252 10 UIKit -[UICollectionView _updateVisibleCellsNow:] + 2672 11 UIKit -[UICollectionView layoutSubviews] + 214 12 UIKit …
我已经阅读了很多关于这个问题的内容,但我似乎仍然有所不同.所以根据我的理解,EXC_BAD_ACCESS会出现内存管理问题.
事情是,我的似乎不是(!:)).问题是,我简单地在IB中添加了一个按钮,圆角矩形,没有图像.我把它与我班上定义的IBACTION联系在一起.顺便说一句,这个方法什么都不做(!).
无论如何,只要我点击按钮,应用程序崩溃就会出现"EXC_BAD_ACCESS".
就我所知,我肯定不会过度释放任何东西.有什么问题?
有线索吗?
这是我的控制台日志:
Loading program into debugger…
sharedlibrary apply-load-rules all
Program loaded.
target remote-mobile /tmp/.XcodeGDBRemote-148-79
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
run
Running…
[Switching to thread 11779]
[Switching to thread 11779]
(gdb) continue
2010-01-15 09:16:34.800 FlightControl1[1899:207] Table loaded
2010-01-15 09:16:35.200 FlightControl1[1899:207] 23
2010-01-15 09:16:35.350 FlightControl1[1899:207] debug
Program received signal: “EXC_BAD_ACCESS”.
(gdb)
Run Code Online (Sandbox Code Playgroud)
在我上堆栈之后,这就是我得到的:
#0 0x31ec3ebc in objc_msgSend ()
#1 0x33605784 in -[UIApplication sendAction:to:from:forEvent:] ()
#2 0x336056ec in -[UIApplication …Run Code Online (Sandbox Code Playgroud) exc-bad-access ×10
iphone ×5
ios ×4
objective-c ×3
swift ×2
c ×1
c++ ×1
debugging ×1
ios6 ×1
nsurlsession ×1
uialertview ×1
uibutton ×1
uikit ×1
uiresponder ×1
uiscrollview ×1
uiwebview ×1
xcode ×1
xcode4.5 ×1