Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios xcode不可理解异常_Ios_Xcode - Fatal编程技术网

Ios xcode不可理解异常

Ios xcode不可理解异常,ios,xcode,Ios,Xcode,我正在编写ios应用程序,它从ip摄像头接收帧,并用UIImage和定时器显示它们。但有时我会遇到一个无法理解的例外。 这是一堆 thread#1:tid=0x72198,0x0553a240 vImage`vConvert_rgb888tobgra888+1760,queue='com.apple.main thread',stop reason=EXC_BAD_ACCESS(代码=1,地址=0xe429000) 帧#0:0x0553a240 vImage`vConvert_RGB888 To

我正在编写ios应用程序,它从ip摄像头接收帧,并用UIImage和定时器显示它们。但有时我会遇到一个无法理解的例外。
这是一堆

thread#1:tid=0x72198,0x0553a240 vImage`vConvert_rgb888tobgra888+1760,queue='com.apple.main thread',stop reason=EXC_BAD_ACCESS(代码=1,地址=0xe429000)
帧#0:0x0553a240 vImage`vConvert_RGB888 TobGra888+1760
帧#1:0x05523280 vImage`vImageConvert_RGB888 TobGra888+96
帧#2:0x01f2f1aa CoreGraphics`CGSConvertBGR888toRGBA8888+165
帧#3:0x01f5a83e CoreGraphics`argb32_图像+4830
帧#4:0x0ae007ad libRIP.A.dylib`ripl#U标记+38
帧#5:0x0ae101e1 libRIP.A.dylib`RIPLayerBltImage+1187
帧#6:0x0adfcc59 libRIP.A.dylib`ripc#u渲染+258
帧#7:0x0adfb0cb libRIP.A.dylib`ripc#u DrawImage+1051
帧#8:0x01fe4865 CoreGraphics`CGContextDrawImage+435
帧#9:0x01657498 QuartzCore`CA::Render::(匿名命名空间)::通过渲染创建图像(CGImage*,CGColorSpace*,unsigned int)+708
帧#10:0x01656f31 QuartzCore`CA::Render::create#u image(CGImage*,CGColorSpace*,unsigned int)+2261
帧#11:0x0165784d QuartzCore`CA::Render::copy#U图像(CGImage*,CGColorSpace*,无符号整数,双精度)+430
帧#12:0x01738d10 QuartzCore`-[CALayer(CALayerPrivate)\u copyRenderLayer:layerFlags:commitFlags:+557
帧#13:0x0173a031 QuartzCore`CA::Layer::copy_render_Layer(CA::Transaction*,unsigned int,unsigned int*)+57
帧#14:0x0168fc9d QuartzCore`CA::Context::commit_层(CA::layer*,unsigned int,unsigned int,void*)+119
帧#15:0x0172a727 QuartzCore`CA::Layer::commit_(如果需要)(CA::Transaction*,void(*)(CA::Layer*,unsigned int,unsigned int,void*))+317
帧#16:0x0172a6a7 QuartzCore`CA::Layer::commit_如果需要(CA::Transaction*,void(*)(CA::Layer*,unsigned int,unsigned int,void*))+189
帧#17:0x0172a6a7 QuartzCore`CA::Layer::commit_如果需要(CA::Transaction*,void(*)(CA::Layer*,unsigned int,unsigned int,void*))+189
帧#18:0x01690dd6 QuartzCore`CA::Context::commit#U事务(CA::transaction*)+1794
帧#19:0x01691b85 QuartzCore`CA::Transaction::commit()+393
帧#20:0x0174f5b0 QuartzCore`+[CATransaction flush]+52
帧#21:0x021909b6 UIKit`\u UIWindowUpdateVisibleContextOrder+232
帧#22:0x02190825 UIKit`+[UIWindow\u准备文件的内部传递测试:][28
帧#23:0x02190a0f UIKit`+[UIWindow _prepareWindowsForAppResume]+41
帧#24:0x02164972 UIKit`-[UIApplication\u handleApplicationResumeEvent:+80
帧#25:0x0216593f UIKit`-[UIApplication handleEvent:withNewEvent:+1898
帧#26:0x02166555 UIKit`-[UIApplication sendEvent:+85
帧#27:0x02153250 UIKit`\u UIApplicationHandleEvent+683
帧#28:0x04c6bf02图形服务`(u PurpleEventCallback+776)
帧29:0x04c6ba0d图形服务“PurpleEventCallback+46”
帧#30:0x0368eca5 CoreFoundation`\uuuuu CFRUNLOOP\u正在调用\uu OUT\u到\u A\u SOURCE1\u PERFORM\u函数\uuu+53
帧#31:0x0368e9db CoreFoundation`\uu CFRunLoopDoSource1+523
帧#32:0x036b968c CoreFoundation`u CFRunLoopRun+2156
帧#33:0x036b89d3 CoreFoundation`CFRunLoopRunSpecific+467
帧#34:0x036b87eb CoreFoundation`CFRunLoopRunInMode+123
帧35:0x04c6a5ee GraphicsServices`GSEventRunModal+192
帧#36:0x04c6a42b图形服务`GSEventRun+104
帧#37:0x02152f9b UIKit`UIApplicationMain+1225
帧#38:0x00009344瘦客户端v2`main(argc=1,argv=0xbffee4c)+164位于main处。m:17
但我认为这并没有真正的帮助,所以我如何理解哪行代码引发了异常? 我添加了所有异常断点和技巧,但对我没有帮助

谢谢

PS
所以我将僵尸对象添加到我的项目中。据我所知,它将帮助我获得更正确的堆栈跟踪。
关于创建图像。这是我的密码

- (UIImage *)imageFromAVPicture:(AVPicture)pict width:(int)width height:(int)height    
{
    CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
    CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, pict.data[0], pict.linesize[0]*height,kCFAllocatorNull);
    CGDataProviderRef provider = CGDataProviderCreateWithCFData(data);
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGImageRef cgImage = CGImageCreate(width, 
                                       height, 
                                       8, 
                                       24, 
                                       pict.linesize[0], 
                                       colorSpace, 
                                       bitmapInfo, 
                                       provider, 
                                       NULL, 
                                       NO, 
                                       kCGRenderingIntentDefault);
    CGColorSpaceRelease(colorSpace);
    UIImage *image = [UIImage imageWithCGImage:cgImage];

    CGImageRelease(cgImage);
    CGDataProviderRelease(provider);
    CFRelease(data);

    return image;
}

但我认为如果问题出在这个方法上,它会一直崩溃,对吗?但异常发生的情况非常罕见。

这意味着你的应用程序正在崩溃,因为它触及了未映射的内存


如果使用CGDataProviderRef创建CGImageRef(该CGDataProviderRef已初始化,没有副本),然后在CGImageRef死亡之前释放像素,则通常会发生这种情况。这将留下一个指向垃圾的CGImageRef,如果您试图绘制垃圾,它将崩溃。如果您非常确定自己没有这样做,并且可以拿出一个可复制的示例案例,那么我建议您向苹果公司提交一个bug:

EXC\u BAD\u ACCESS是一个Mach异常,而不是Objective-C异常。除了Ian Ollmann所写的内容之外,您还将
kCFAllocatorDefault
传递给
CFDataCreateWithBytesNoCopy
。因此,当您的
数据
对象解除分配时,它将尝试使用默认分配器释放
pict.data[0]
处的内存。这可能不是您想要的。我想我应该使用CGDataProviderCreateWithData()创建数据提供程序,并保留AVPicture。在release回调中,我将释放AVPicture。(假设AVPicture是引用计数的。)看起来像是来自FFmpeg。哦,好吧。任何拥有AVPicture的人都必须推迟删除它,直到调用之后。