仅在 iPad 模拟器 (<= 4.3) 中发生奇怪的崩溃 (EXC_BAD_ACCESS) - 有什么想法吗?

发布于 2024-12-11 07:34:55 字数 2984 浏览 1 评论 0 原文

有时,我仅在模拟器中遇到非常奇怪的崩溃(<= 4.3)。当我按下嵌入弹出窗口的导航控制器上的按钮时,就会发生这种情况。在弹出窗口下有一个正在渲染某些内容的 EAGLView。内存处理正确,等等......在设备上完全没有问题。

有什么想法吗?

这是一个调用堆栈:

* thread #1: tid = 0x2c03, 0x00ab6707 CoreGraphics`CGColorGetAlpha + 17, stop reason = EXC_BAD_ACCESS (code=1, address=0x1cc9b72c)
frame #0: 0x00ab6707 CoreGraphics`CGColorGetAlpha + 17
frame #1: 0x00dc9871 QuartzCore`-[CALayer _renderBackgroundInContext:] + 97
frame #2: 0x00dc97af QuartzCore`-[CALayer renderInContext:] + 977
frame #3: 0x00dcf15c QuartzCore`-[CALayer _renderSublayersInContext:] + 444
frame #4: 0x00dc97e1 QuartzCore`-[CALayer renderInContext:] + 1027
frame #5: 0x00dcf15c QuartzCore`-[CALayer _renderSublayersInContext:] + 444
frame #6: 0x00dc97e1 QuartzCore`-[CALayer renderInContext:] + 1027
frame #7: 0x003434a9 UIKit`-[UIView(Internal) _renderSnapshotWithRect:inContext:] + 790
frame #8: 0x0067776d UIKit`-[UIClipCornerView _updateSnapshot] + 697
frame #9: 0x0067723c UIKit`-[UIRoundedCornerView didMoveToSuperview] + 51
frame #10: 0x0033c750 UIKit`-[UIView(Internal) _addSubview:positioned:relativeTo:] + 1080
frame #11: 0x0033aaa3 UIKit`-[UIView(Hierarchy) addSubview:] + 57
frame #12: 0x004df1ad UIKit`-[UILayoutContainerView _beginFastMode] + 259
frame #13: 0x003c0c74 UIKit`-[UIViewController(UINavigationControllerItem) setEditing:animated:] + 249
frame #14: 0x0051453b UIKit`-[UITableViewController setEditing:animated:] + 73
frame #15: 0x003b6d1e UIKit`-[UIViewController(UINavigationControllerItem) _toggleEditing:] + 77
frame #16: 0x0030b4fd UIKit`-[UIApplication sendAction:to:from:forEvent:] + 119
frame #17: 0x0051dcc3 UIKit`-[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
frame #18: 0x0030b4fd UIKit`-[UIApplication sendAction:to:from:forEvent:] + 119
frame #19: 0x0039b799 UIKit`-[UIControl sendAction:to:forEvent:] + 67
frame #20: 0x0039dc2b UIKit`-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
frame #21: 0x0039c7d8 UIKit`-[UIControl touchesEnded:withEvent:] + 458
frame #22: 0x0032fded UIKit`-[UIWindow _sendTouchesForEvent:] + 567
frame #23: 0x00310c37 UIKit`-[UIApplication sendEvent:] + 447
frame #24: 0x00315f2e UIKit`_UIApplicationHandleEvent + 7576
frame #25: 0x018f0992 GraphicsServices`PurpleEventCallback + 1550
frame #26: 0x00f79944 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
frame #27: 0x00ed9cf7 CoreFoundation`__CFRunLoopDoSource1 + 215
frame #28: 0x00ed6f83 CoreFoundation`__CFRunLoopRun + 979
frame #29: 0x00ed6840 CoreFoundation`CFRunLoopRunSpecific + 208
frame #30: 0x00ed6761 CoreFoundation`CFRunLoopRunInMode + 97
frame #31: 0x018ef1c4 GraphicsServices`GSEventRunModal + 217
frame #32: 0x018ef289 GraphicsServices`GSEventRun + 115
frame #33: 0x00319c93 UIKit`UIApplicationMain + 1160

还有一件事似乎很重要:当隐藏底层 EAGLView 时,它不会发生。 GLView 和 Popover 不共享任何数据 - 有趣,不是吗?我怀疑当按下按钮(“编辑”)想要重绘/切换到“蓝色”时就会出现这种情况,因为弹出框标题是一种半透明的,所以会发生一些混合。对我来说听起来像是模拟器问题;有人有过类似的事情吗?

感谢您的回答,

wl

Occasionally I am getting a really strange crash in the simulator only (<= 4.3). It happens when I press a button on a navigation controller embedded with in a popover. Under the popover there is an EAGLView which is rendering something. Memory is handled properly, etc... on device no problem at all.

Any idea?

Here is a call stack:

* thread #1: tid = 0x2c03, 0x00ab6707 CoreGraphics`CGColorGetAlpha + 17, stop reason = EXC_BAD_ACCESS (code=1, address=0x1cc9b72c)
frame #0: 0x00ab6707 CoreGraphics`CGColorGetAlpha + 17
frame #1: 0x00dc9871 QuartzCore`-[CALayer _renderBackgroundInContext:] + 97
frame #2: 0x00dc97af QuartzCore`-[CALayer renderInContext:] + 977
frame #3: 0x00dcf15c QuartzCore`-[CALayer _renderSublayersInContext:] + 444
frame #4: 0x00dc97e1 QuartzCore`-[CALayer renderInContext:] + 1027
frame #5: 0x00dcf15c QuartzCore`-[CALayer _renderSublayersInContext:] + 444
frame #6: 0x00dc97e1 QuartzCore`-[CALayer renderInContext:] + 1027
frame #7: 0x003434a9 UIKit`-[UIView(Internal) _renderSnapshotWithRect:inContext:] + 790
frame #8: 0x0067776d UIKit`-[UIClipCornerView _updateSnapshot] + 697
frame #9: 0x0067723c UIKit`-[UIRoundedCornerView didMoveToSuperview] + 51
frame #10: 0x0033c750 UIKit`-[UIView(Internal) _addSubview:positioned:relativeTo:] + 1080
frame #11: 0x0033aaa3 UIKit`-[UIView(Hierarchy) addSubview:] + 57
frame #12: 0x004df1ad UIKit`-[UILayoutContainerView _beginFastMode] + 259
frame #13: 0x003c0c74 UIKit`-[UIViewController(UINavigationControllerItem) setEditing:animated:] + 249
frame #14: 0x0051453b UIKit`-[UITableViewController setEditing:animated:] + 73
frame #15: 0x003b6d1e UIKit`-[UIViewController(UINavigationControllerItem) _toggleEditing:] + 77
frame #16: 0x0030b4fd UIKit`-[UIApplication sendAction:to:from:forEvent:] + 119
frame #17: 0x0051dcc3 UIKit`-[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
frame #18: 0x0030b4fd UIKit`-[UIApplication sendAction:to:from:forEvent:] + 119
frame #19: 0x0039b799 UIKit`-[UIControl sendAction:to:forEvent:] + 67
frame #20: 0x0039dc2b UIKit`-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
frame #21: 0x0039c7d8 UIKit`-[UIControl touchesEnded:withEvent:] + 458
frame #22: 0x0032fded UIKit`-[UIWindow _sendTouchesForEvent:] + 567
frame #23: 0x00310c37 UIKit`-[UIApplication sendEvent:] + 447
frame #24: 0x00315f2e UIKit`_UIApplicationHandleEvent + 7576
frame #25: 0x018f0992 GraphicsServices`PurpleEventCallback + 1550
frame #26: 0x00f79944 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
frame #27: 0x00ed9cf7 CoreFoundation`__CFRunLoopDoSource1 + 215
frame #28: 0x00ed6f83 CoreFoundation`__CFRunLoopRun + 979
frame #29: 0x00ed6840 CoreFoundation`CFRunLoopRunSpecific + 208
frame #30: 0x00ed6761 CoreFoundation`CFRunLoopRunInMode + 97
frame #31: 0x018ef1c4 GraphicsServices`GSEventRunModal + 217
frame #32: 0x018ef289 GraphicsServices`GSEventRun + 115
frame #33: 0x00319c93 UIKit`UIApplicationMain + 1160

One more thing which seems to be important: when underlying EAGLView is hidden then it does not occur. GLView and Popover do not share any data - interesting, is not it? I suspect it comes when pressed button ("edit") wants to redraw/toggle to "blue" then some blending happens since popover heading is a kind of translucent. For me sounds like a simulator problem; anyone had anything like that?

Thanks for any answer,

wl

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡写薰衣草的香 2024-12-18 07:34:56

设置 NSZombieEnabledMallocStackLogging在调试器中保护 malloc。然后,当您的应用程序崩溃时,在 gdb 控制台中输入以下内容:

(gdb) info malloc-history 0x543216

0x543216 替换为导致崩溃的对象的地址(可能来自此行:* thread #1: tid = 0x2c03 , 0x00ab6707 CoreGraphics CGColorGetAlpha + 17, 停止原因 = EXC_BAD_ACCESS (代码=1, address=0x1cc9b72c)),您将获得更有用的堆栈跟踪,它应该可以帮助您查明代码中导致问题的确切行。

请参阅本文以获取更详细的说明。

Set NSZombieEnabled, MallocStackLogging, and guard malloc in the debugger. Then, when your App crashes, type this in the gdb console:

(gdb) info malloc-history 0x543216

Replace 0x543216 with the address of the object that caused the crash (probably from this line: * thread #1: tid = 0x2c03, 0x00ab6707 CoreGraphics CGColorGetAlpha + 17, stop reason = EXC_BAD_ACCESS (code=1, address=0x1cc9b72c)) and you will get a much more useful stack trace and it should help you pinpoint the exact line in your code that is causing the problem.

See this article for more detailed instructions.

中性美 2024-12-18 07:34:56

GDB 给了我类似的东西:

    Alloc: Block address: 0x12387ff0 length: 16
    Stack - pthread: 0xa0014540 number of frames: 38
        0: 0x5fb8e in GMmalloc_zone_malloc_internal
        1: 0x5fd31 in GMmalloc_zone_malloc
        2: 0x60327 in GMmalloc_zone_calloc
        3: 0x60375 in GMcalloc
        4: 0x132a2d4 in class_createInstance
        5: 0xec65d8 in +[NSObject(NSObject) allocWithZone:]
        6: 0x48218e in +[UIColor allocWithZone:]
        7: 0xec63da in +[NSObject(NSObject) alloc]
        8: 0x4812c6 in +[UIColor clearColor]
        9: 0x15b1d in -[EAGLView initWithCoder:]

正如我们所看到的,涉及 EAGLView...

...事实上,经过一番挖掘后,我发现问题与 EAGLLayer 背景颜色有关。我声明如下:

    eaglLayer.backgroundColor = (CGColorRef) [UIColor clearColor];

在那之前这通常工作得很好。

我用:

    CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
    const CGFloat clearColor[] = {0.0, 0.0, 0.0, 0.0};
    eaglLayer.backgroundColor = CGColorCreate(rgb, clearColor);
    CGColorSpaceRelease(rgb); 

或更短:

    eaglLayer.backgroundColor = [UIColor clearColor].CGColor;

从那以后也不例外。

@chown:谢谢你的提示。

GDB gives me something like that:

    Alloc: Block address: 0x12387ff0 length: 16
    Stack - pthread: 0xa0014540 number of frames: 38
        0: 0x5fb8e in GMmalloc_zone_malloc_internal
        1: 0x5fd31 in GMmalloc_zone_malloc
        2: 0x60327 in GMmalloc_zone_calloc
        3: 0x60375 in GMcalloc
        4: 0x132a2d4 in class_createInstance
        5: 0xec65d8 in +[NSObject(NSObject) allocWithZone:]
        6: 0x48218e in +[UIColor allocWithZone:]
        7: 0xec63da in +[NSObject(NSObject) alloc]
        8: 0x4812c6 in +[UIColor clearColor]
        9: 0x15b1d in -[EAGLView initWithCoder:]

As we can see EAGLView is involved...

...and in fact after some digging I figured out the problem was to do with EAGLLayer background color. I declared it as follows:

    eaglLayer.backgroundColor = (CGColorRef) [UIColor clearColor];

This generally worked fine until then.

I fixed it with:

    CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
    const CGFloat clearColor[] = {0.0, 0.0, 0.0, 0.0};
    eaglLayer.backgroundColor = CGColorCreate(rgb, clearColor);
    CGColorSpaceRelease(rgb); 

or shorter:

    eaglLayer.backgroundColor = [UIColor clearColor].CGColor;

Since then no exception.

@chown: thanks for your tip.

wl

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文