isBeaconInsideZoneAndDwellTime

isBeaconInsideZoneAndDwellTime

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

设备上的我的应用程序(特别是发行版)发生崩溃。

崩溃日志是:

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)

任何帮助,将不胜感激。

谢谢

添加更多详细信息[ call 者摘要]
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

最佳答案

EXC_ARM_DA_ALIGN将指示您的代码正在尝试使用isbeaconInsideZoneAndDwellTime内部未正确对齐的变量。

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

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

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

如果您可以向我们展示LtsbeaconProximity的结构,那对我们有帮助。

关于ios - iOS应用程序在设备的发行版中崩溃,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27862717/

10-09 16:15