iOS应用程序在设备上的发行版中崩溃

时间:2015-01-09 14:25:52

标签: ios crash release-mode sigbus

我面临一个奇怪的问题,已经花了很多时间在这上面。

我的应用程序中发生崩溃,特别是在设备上的发布版本中。

崩溃日志是:

Incident Identifier: 1879D689-B225-4586-8E8E-D4D9DB392ABB
CrashReporter Key:   c432ffa8a13433b330d0fc03863778260c00be45
Hardware Model:      iPhone5,3
Process:             CSR Proximity [5696]
Path:                /var/mobile/Applications/4C6CDC7D-E594-4976-923B-0A62B68C0053/CSR Proximity.app/CSR Proximity
Identifier:          com.csr.proximity.app.beacon
Version:             37_release (1.2.0_i)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2015-01-09 19:46:08.903 +0530
OS Version:          iOS 7.1.2 (11D257)
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Subtype: EXC_ARM_DA_ALIGN at 0x03a3d4fe
Triggered by Thread:  13

Thread 0:
0   libsystem_kernel.dylib          0x3930ca50 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3930c848 mach_msg + 36
2   CoreFoundation                  0x2e59a5e4 __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x2e598d4a __CFRunLoopRun + 858
4   CoreFoundation                  0x2e503724 CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x2e503506 CFRunLoopRunInMode + 102
6   GraphicsServices                0x334726ce GSEventRunModal + 134
7   UIKit                           0x30e6486c UIApplicationMain + 1132
8   CSR Proximity                   0x0000a042 main (main.m:17)
9   libdyld.dylib                   0x39268ab4 start + 0

Thread 1:
0   libsystem_kernel.dylib          0x3930c804 kevent64 + 24
1   libdispatch.dylib               0x3925b050 _dispatch_mgr_invoke + 228
2   libdispatch.dylib               0x392552de _dispatch_mgr_thread + 34

Thread 2:
0   libsystem_kernel.dylib          0x3931fc70 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39384c1e _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 3:
0   libsystem_kernel.dylib          0x3931fc70 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39384c1e _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 4:
0   libsystem_kernel.dylib          0x3931fc70 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39384c1e _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 5:
0   libsystem_kernel.dylib          0x3931fc70 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39384c1e _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 6:
0   CoreData                        0x2e359cc2 +[_PFRoutines newMutableSetFromCollection:byRemovingItems:] + 846
1   CoreData                        0x2e3591a4 -[NSSQLCore recordToManyUpdatesForObject:withOperation:] + 1408
2   CoreData                        0x2e3589f0 -[NSSQLCore recordUpdateForObject:] + 92
3   CoreData                        0x2e357234 -[NSSQLCore recordChangesInContext:] + 576
4   CoreData                        0x2e354640 -[NSSQLCore saveChanges:] + 704
5   CoreData                        0x2e322c9a -[NSSQLCore executeRequest:withContext:error:] + 462
6   CoreData                        0x2e322588 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 2972
7   CoreData                        0x2e343f44 -[NSManagedObjectContext save:] + 820
8   CSR Proximity                   0x000a239e -[CPSController sendProximityUpdateNotification:] (CPSController.m:1542)
9   CSR Proximity                   0x0009d988 -[CPSController placesWithCompletionBle::] (CPSController.m:1017)
10  CSR Proximity                   0x0009ecd0 -[CPSController updateDataStoreProximitiesForBeacons::] (CPSController.m:1069)
11  CSR Proximity                   0x0009f3ec -[CPSController handleCurrentBeacons:collectEntities:] (CPSController.m:1124)
12  CSR Proximity                   0x0009f1e0 -[CPSController handleCurrentBeacons:deleted:] (CPSController.m:1104)
13  CSR Proximity                   0x001349e4 -[BleThreadPayLoad process] (BleThreadPayLoad.m:996)
14  CSR Proximity                   0x00133904 -[BleThreadPayLoad threadRunLoop] (BleThreadPayLoad.m:509)
15  CSR Proximity                   0x001339aa -[BleThreadPayLoad main] (BleThreadPayLoad.m:531)
16  Foundation                      0x2efb9a0a __NSThread__main__ + 1058
17  libsystem_pthread.dylib         0x39386956 _pthread_body + 138
18  libsystem_pthread.dylib         0x393868c6 _pthread_start + 98
19  libsystem_pthread.dylib         0x39384ae4 thread_start + 4

Thread 7 name:  com.apple.NSURLConnectionLoader
Thread 7:
0   libsystem_kernel.dylib          0x3930ca50 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3930c848 mach_msg + 36
2   CoreFoundation                  0x2e59a5e4 __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x2e598d04 __CFRunLoopRun + 788
4   CoreFoundation                  0x2e503724 CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x2e503506 CFRunLoopRunInMode + 102
6   Foundation                      0x2ef4423c +[NSURLConnection(Loader) _resourceLoadLoop:] + 316
7   Foundation                      0x2efb9a0a __NSThread__main__ + 1058
8   libsystem_pthread.dylib         0x39386956 _pthread_body + 138
9   libsystem_pthread.dylib         0x393868c6 _pthread_start + 98
10  libsystem_pthread.dylib         0x39384ae4 thread_start + 4

Thread 8:
0   libsystem_kernel.dylib          0x3930ca50 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x3930c848 mach_msg + 36
2   CoreFoundation                  0x2e59a5e4 __CFRunLoopServiceMachPort + 152
3   CoreFoundation                  0x2e598d04 __CFRunLoopRun + 788
4   CoreFoundation                  0x2e503724 CFRunLoopRunSpecific + 520
5   CoreFoundation                  0x2e503506 CFRunLoopRunInMode + 102
6   Foundation                      0x2eef7492 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7   CSR Proximity                   0x000fa41a -[CPSAutoFetchController threadRunLoop:] (CPSAutoFetchController.m:333)
8   Foundation                      0x2efb9a0a __NSThread__main__ + 1058
9   libsystem_pthread.dylib         0x39386956 _pthread_body + 138
10  libsystem_pthread.dylib         0x393868c6 _pthread_start + 98
11  libsystem_pthread.dylib         0x39384ae4 thread_start + 4

Thread 9:
0   libsystem_kernel.dylib          0x3931fc70 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39384c1e _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 10:
0   libsystem_kernel.dylib          0x3931fc70 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39384c1e _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 11 name:  com.apple.CFSocket.private
Thread 11:
0   libsystem_kernel.dylib          0x3931f434 __select + 20
1   CoreFoundation                  0x2e59e4de __CFSocketManager + 482
2   libsystem_pthread.dylib         0x39386956 _pthread_body + 138
3   libsystem_pthread.dylib         0x393868c6 _pthread_start + 98
4   libsystem_pthread.dylib         0x39384ae4 thread_start + 4

Thread 12:
0   libsystem_kernel.dylib          0x3931fc70 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39384c1e _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 13 Crashed:
0   CSR Proximity                   0x0010fff4 checkSimpleEvent (lts_sdk_eval.c:560)
1   CSR Proximity                   0x001108b8 checkEvent (lts_sdk_eval.c:964)
2   CSR Proximity                   0x0011068c checkComplexEvent (lts_sdk_eval.c:1009)
3   CSR Proximity                   0x001108a2 checkEvent (lts_sdk_eval.c:971)
4   CSR Proximity                   0x00110962 Evaluate (lts_sdk_eval.c:1106)
5   CSR Proximity                   0x0010f0a2 -[CPSEventManager evaluate:] (CPSEventManager.m:170)
6   CoreFoundation                  0x2e5d3410 __invoking___ + 64
7   CoreFoundation                  0x2e51d962 -[NSInvocation invoke] + 282
8   Foundation                      0x2efa6d04 -[NSInvocationOperation main] + 108
9   Foundation                      0x2ef04870 -[__NSOperationInternal _start:] + 768
10  Foundation                      0x2efa8740 __NSOQSchedule_f + 56
11  libdispatch.dylib               0x39258cb8 _dispatch_queue_drain + 484
12  libdispatch.dylib               0x39255c6a _dispatch_queue_invoke + 38
13  libdispatch.dylib               0x392595ee _dispatch_root_queue_drain + 74
14  libdispatch.dylib               0x392598d8 _dispatch_worker_thread2 + 52
15  libsystem_pthread.dylib         0x39384c14 _pthread_wqthread + 296
16  libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 14:
0   libsystem_kernel.dylib          0x3931fc70 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x39384c1e _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x39384ad8 start_wqthread + 4

Thread 13 crashed with ARM Thread State (32-bit):
    r0: 0x03a3d4fe    r1: 0x00000000      r2: 0x14f46000      r3: 0x00000002
    r4: 0x00000007    r5: 0x14f27085      r6: 0x03a3d4ee      r7: 0x03a3d6e0
    r8: 0x03a3d675    r9: 0x00000fff     r10: 0x14f27084     r11: 0x00000006
    ip: 0x3b275118    sp: 0x03a3c464      lr: 0x0010ffdb      pc: 0x0010fff4
  cpsr: 0x00000030

我知道有一些与字节对齐有关的问题。但是我不知道自己需要做什么。

崩溃位置代码段是对以下内容的有效值函数调用:

static LtsEventStatus isBeaconInsideZoneAndDwellTime( const LtsBeaconProximityEvent* eventData,
    const LtsBeaconProximity  reportData, tSIRF_UINT8 isReverse, tSIRF_BOOL* found, tSIRF_UINT8 index)

任何帮助将不胜感激。

由于

添加更多详细信息[来电代码段]

LtsServerConfigureLocal *cfg = GetConfiguration();
    LtsEventAttribute *attr;
    LtsEventStatus flag = LTS_FALSE;
    int beaconIndx = 0;
    tSIRF_UINT8 reverse;
    tSIRF_BOOL found;
    LtsEventResults* eventsResult;
    LtsProximalBeacons beacons = values->proximalBeacons;

    CCSE_INFO("BeaconFence: Index : %d, values count: %d\n", index, values->proximalBeacons.nValues);

    CCSE_INFO("BeaconFence 1");

    if( event->values.internal.value >= cfg->nAttributesCnt ) {
        CCSE_ERROR("Invalid LtsProximalBeacons index %d\n", event->values.internal.value );
        return LTS_FALSE; // error
    }
    CCSE_INFO("BeaconFence 2: %d", event->values.internal.value);
    attr = & cfg->attributes[ event->values.internal.value ];

    found = FALSE;
    reverse = 0x0F & ((event->values.internal.attributes & LTS_MASK_REVERSE)? 1: 0);
    CCSE_INFO("BeaconFence 3");

    //multiple beacons data
    for( ; beaconIndx < beacons.nValues ; beaconIndx++)
    {
        CCSE_INFO("BeaconFence 41");

        const LtsBeaconProximityEvent* eventData = NULL;
        const LtsBeaconProximity  *reportData = NULL;
        eventData = &attr->attribute.beaconProximity;
        CCSE_INFO("BeaconFence 411, eventData: %p, ", eventData );

        CCSE_INFO("BeaconFence 412, reportData:%p, beaconIndx: %p ",&beacons.values[beaconIndx], &beaconIndx );

        LtsBeaconProximity beacon = (eventData->proximalBeacon);
        reportData = &beacons.values[beaconIndx];
       // CCSE_INFO("eventData: nBeaconId: %d address of beaconid: %p, zone: %d, dwellTime: %f", beacon.beaconId, beacon.beaconId[5], beacon.zone, beacon.dwellTime);

        CCSE_INFO("Beacon Fence 413");

        CCSE_INFO("reportData: nBeaconId: %d beaconid: %s, dwellTime: %f, zone: %d, ", reportData->nBeaconId, reportData->beaconId, reportData->dwellTime, reportData->zone);



//        flag = isBeaconInsideZoneAndDwellTime( & attr->attribute.beaconProximity, beacons.values[beaconIndx], reverse, &found, index);
        flag = isBeaconInsideZoneAndDwellTime( eventData, beacons.values[beaconIndx], reverse, &found, index);

        CCSE_INFO("BeaconFence 42");
        if(found)
            break;
    }

问题是日志“BeaconFence 42”从未打印过。调用isBeaconInsideZoneAndDwellTime时代码崩溃。在控制台日志中,我们得到了sigbus 10

2 个答案:

答案 0 :(得分:1)

EXC_ARM_DA_ALIGN表示您的代码正在尝试使用isBeaconInsideZoneAndDwellTime内未正确对齐的变量。

根据你对值的传递而不是地址的注释,这意味着isBeaconInsideZoneAndDwellTime中的代码对调用它的代码的LtsBeaconProximity结构的布局有不同的看法。当传递值时,字节被复制,因此isBeaconInsideZoneAndDwellTime内的代码正在处理其LtsBeaconProximity结构布局的版本。假设存在对齐问题,在这种情况下,您会在结构中看到错误的值而不是SIGBUS。但是,如果坏值为0或者未使用的区域,您可能会使用它。当通过地址传递时,内部的代码isBeaconInsideZoneAndDwellTime基于其对LtsbeaconProximity结构布局的理解使用偏移和类型,但是使用偏移量来理解该结构的调用代码。这里使用变量会触发对齐问题,因为两者必须不匹配。

我会在调用代码中添加一些调试,以打印出相对于起始地址和大小的结构内容的偏移量。然后将相同的代码粘贴到isBeaconInsideZoneAndDwellTime中。如果代码未对齐,您将看到不同的偏移量。

一个简单的起点是在函数内部和外部打印sizeof(LtsbeaconProximity)。如果不同,那么你知道它是一个问题。

如果您能向我们展示LtsbeaconProximity的结构,这将有助于我们思考。

答案 1 :(得分:0)

好吧,我不知道为什么要修复它。但我已经在很多ARM架构和iOS设备上尝试过它,看来我通过引用传递第二个参数后崩溃已经消失。