简体   繁体   English

iOS应用程序仅在未调试时崩溃

[英]iOS app crash only when not debugging

I am using testflight to test my app, and I have a crash that only occurs when the app is built for ad-hoc and distributed through test flight. 我正在使用testflight来测试我的应用程序,并且我发生了崩溃,只有当应用程序是为ad-hoc构建并通过测试飞行分发时才会发生。 The relevant crash report details are: 相关的崩溃报告详细信息如下:

Date/Time:       2012-06-11 09:00:34.638 +0800
OS Version:      iPhone OS 5.1.1 (9B206)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000009
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x34e74f78 objc_msgSend + 16
1   appName                         0x0002963e __24-[XYPieChart reloadData]_block_invoke_0168 (XYPieChart.m:321)
2   libdispatch.dylib               0x30295c52 _dispatch_call_block_and_release + 6
3   libdispatch.dylib               0x302a0e8a _dispatch_main_queue_callback_4CF$VARIANT$up + 190
4   CoreFoundation                  0x371482a6 __CFRunLoopRun + 1262
5   CoreFoundation                  0x370cb49e CFRunLoopRunSpecific + 294
6   CoreFoundation                  0x370cb366 CFRunLoopRunInMode + 98
7   GraphicsServices                0x3388a432 GSEventRunModal + 130
8   UIKit                           0x30e77cce UIApplicationMain + 1074
9   appName                         0x00003b20 main (main.m:14)
10  appName                         0x00003ad8 0x1000 + 10968

and the code that is referenced - (XYPieChart.m:321) 和引用的代码 - (XYPieChart.m:321)

    [CATransaction begin];
    [CATransaction setAnimationDuration:_animationSpeed];

    [_pieView setUserInteractionEnabled:NO];

    __block NSMutableArray *layersToRemove = nil;
    [CATransaction setCompletionBlock:^{

        if (layersToRemove) {
            [layersToRemove enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                if (obj)
                    [obj removeFromSuperlayer];
            }];

            [layersToRemove removeAllObjects];
        }

        for(SliceLayer *layer in _pieView.layer.sublayers)
        {
            [layer setZPosition:kDefaultSliceZOrder];
        }

        [_pieView setUserInteractionEnabled:YES];
    }];

    BOOL isOnStart = ([slicelayers count] == 0 && sliceCount);
    NSInteger diff = sliceCount - [slicelayers count];
    layersToRemove = [NSMutableArray arrayWithArray:slicelayers];

    BOOL isOnEnd = ([slicelayers count] && (sliceCount == 0 || sum <= 0));
    if(isOnEnd)
    {
        for(SliceLayer *layer in _pieView.layer.sublayers){
            [self updateLabelForLayer:layer value:0];
            [layer createArcAnimationForKey:@"startAngle"
                                  fromValue:[NSNumber numberWithDouble:_startPieAngle]
                                    toValue:[NSNumber numberWithDouble:_startPieAngle] 
                                   Delegate:self];
            [layer createArcAnimationForKey:@"endAngle" 
                                  fromValue:[NSNumber numberWithDouble:_startPieAngle]
                                    toValue:[NSNumber numberWithDouble:_startPieAngle] 
                                   Delegate:self];
        }
        [CATransaction commit];
        return;
    }

I would be able to track down the problem if I could reproduce it when debugging but it only seems to occur when built for ad-hoc. 如果我可以在调试时重现它,我将能够追踪问题,但它似乎只在为ad-hoc构建时发生。 Thanks! 谢谢!

Edit: Using the simulator, I have tracked down the problem to a EXC_BAD_ACCESS at this line 编辑:使用模拟器,我已将问题跟踪到此行的EXC_BAD_ACCESS

[layersToRemove enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {

Change your Xcode Scheme so that you can Test and Debug a Release build, which uses the same compiler optimizations as your Ad Hoc build. 更改您的Xcode Scheme,以便您可以测试和调试Release版本,该版本使用与Ad Hoc构建相同的编译器优化。 Debugging a Debug build does not. 调试Debug构建不会。

I had a similar problem and tried changing the project build settings, but it didn't work for me. 我有类似的问题,并尝试更改项目构建设置,但它不适合我。 Eventually solved my problem by changing the compiler optimization level setting for the release: 最终通过更改发布的编译器优化级别设置解决了我的问题:

In Build Settings, go to the LLVM compiler 4.2 - Code Generation section, look for the Optimization Level option and change the Release setting from Fastest, Smallest [-Os] to None [-O0]. 在Build Settings中,转到LLVM编译器4.2 - 代码生成部分,查找优化级别选项并将Release设置从Fastest,Smallest [-Os]更改为None [-O0]。

Hope this helps! 希望这可以帮助!

I ended up working out the problem. 我最终解决了这个问题。 In my compiler settings, somehow, ARC wasn't enabled for Ad-Hoc builds resulting in weird behaviour. 在我的编译器设置中,不知何故,ARC没有为Ad-Hoc构建启用,导致奇怪的行为。 Before I worked this out, allocating the __block variable worked because in non-ARC environments, __block variables are not retained automatically. 在我解决之前,分配__block变量是有效的,因为在非ARC环境中,__block变量不会自动保留。

Changed compiler settings so that all builds use ARC and everything was fixed. 更改了编译器设置,以便所有构建都使用ARC并且所有内容都已修复。

In my case it was the "Enable Zombie Objects" setting that prevented the crash in debug mode. 在我的例子中,它是“启用僵尸对象”设置,可防止在调试模式下崩溃。 Debuggin without this setting made the app also crash in the debugger making it easy to find the culprit. 没有这个设置的Debuggin使得应用程序也在调试器中崩溃,从而轻松找到罪魁祸首。

So I would advice to disable all settings in the "diagnostics" menu and set the optimizations to -Os and make a final test before releasing. 所以我建议禁用“诊断”菜单中的所有设置,并将优化设置为-Os并在发布之前进行最终测试。 Or as hotpaw2 pointed out, build in release mode. 或者正如hotpaw2指出的那样,构建在发布模式中。 But this did not work for me due to issues with the certificate settings. 但由于证书设置问题,这对我不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM