我有一个通过附件端口与设备通信的应用程序。当设备向iPhone发送数据(以每20毫秒一个13字节数据包的速率,所以不是很快)时,如果我按下主页按钮将应用程序发送到后台,然后再次打开它会崩溃。我已经向UIApplicationDidBecomeActiveNotification
和UIApplicationWillResignActiveNotification
添加了监听器,以便在应用程序进入后台时关闭数据传输,并在它返回时将其重新打开,现在它不会全部崩溃时间,但不规律。当它崩溃时,它甚至在发送UIApplicationDidBecomeActiveNotification
之前就会崩溃。
以下是错误的设备日志:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000004
Crashed Thread: 3
Thread 0:
0 libSystem.B.dylib 0x000016a8 semaphore_wait_trap + 8
1 libSystem.B.dylib 0x0002ed9e semaphore_wait + 2
2 libSystem.B.dylib 0x000d7ce4 _dispatch_semaphore_wait_slow + 296
3 libSystem.B.dylib 0x000d64a0 _dispatch_barrier_sync_f_slow + 128
4 CoreFoundation 0x0001511e CFMachPortCreateRunLoopSource + 118
5 QuartzCore 0x00005466 CA::Context::client_port() + 78
6 QuartzCore 0x00005310 CA::Context::connect_remote() + 244
7 QuartzCore 0x00004fda -[CAContextImpl initRemoteWithOptions:] + 26
8 QuartzCore 0x00004f9c +[CAContext remoteContextWithOptions:] + 28
9 UIKit 0x0000dae0 -[UIWindow _createContext] + 532
10 UIKit 0x0015957e _UIWindowUpdateVisibleContextOrder + 98
11 UIKit 0x0015962a +[UIWindow _prepareWindowsForAppResume] + 10
12 UIKit 0x00152824 -[UIApplication _handleApplicationResumeEvent:] + 68
13 UIKit 0x0005da80 -[UIApplication handleEvent:withNewEvent:] + 3772
14 UIKit 0x0005ca56 -[UIApplication sendEvent:] + 38
15 UIKit 0x0005c500 _UIApplicationHandleEvent + 5016
16 GraphicsServices 0x00004140 PurpleEventCallback + 660
17 GraphicsServices 0x000041ca PurpleEventSignalCallback + 10
18 CoreFoundation 0x00071a86 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ + 6
19 CoreFoundation 0x000736ac _CFRunLoopDoSources0 + 188
20 CoreFoundation 0x00074504 _CFRunLoopRun + 224
21 CoreFoundation 0x0001d8e4 CFRunLoopRunSpecific + 224
22 CoreFoundation 0x0001d7ec CFRunLoopRunInMode + 52
23 GraphicsServices 0x000036e8 GSEventRunModal + 108
24 GraphicsServices 0x00003794 GSEventRun + 56
25 UIKit 0x000062a0 -[UIApplication _run] + 396
26 UIKit 0x00004e10 UIApplicationMain + 664
27 TestRaspLayer 0x00003034 main (main.m:14)
28 TestRaspLayer 0x00002fe8 start + 32
Thread 1:
0 libSystem.B.dylib 0x0002dc4c kevent + 24
1 libSystem.B.dylib 0x000d6e44 _dispatch_mgr_invoke + 88
2 libSystem.B.dylib 0x000d6894 _dispatch_queue_invoke + 96
3 libSystem.B.dylib 0x000d6a34 _dispatch_worker_thread2 + 120
4 libSystem.B.dylib 0x0007ad82 _pthread_wqthread + 258
5 libSystem.B.dylib 0x00073fcc start_wqthread + 0
Thread 2:
0 libSystem.B.dylib 0x00001658 mach_msg_trap + 20
1 libSystem.B.dylib 0x00003724 mach_msg + 44
2 CoreFoundation 0x000722c8 _CFRunLoopServiceMachPort + 88
3 CoreFoundation 0x00074582 _CFRunLoopRun + 350
4 CoreFoundation 0x0001d8e4 CFRunLoopRunSpecific + 224
5 CoreFoundation 0x0001d7ec CFRunLoopRunInMode + 52
6 WebCore 0x00003056 RunWebThread(void*) + 362
7 libSystem.B.dylib 0x0007a986 _pthread_start + 242
8 libSystem.B.dylib 0x000700e4 thread_start + 0
Thread 3 Crashed:
0 libicucore.A.dylib 0x00001bd0 uhash_get + 24
1 libicucore.A.dylib 0x00055b10 ures_hasNext + 720
2 libicucore.A.dylib 0x00055d08 ures_hasNext + 1224
3 libicucore.A.dylib 0x00055e64 ures_hasNext + 1572
4 libicucore.A.dylib 0x00003a28 ures_openDirect + 80
5 libicucore.A.dylib 0x000b4dee icu::TimeZone::getGMT() + 442
6 libicucore.A.dylib 0x0000861a icu::TimeZone::createSystemTimeZone(icu::UnicodeString const&) + 22
7 libicucore.A.dylib 0x0000cf90 icu::TimeZone::createTimeZone(icu::UnicodeString const&) + 4
8 libicucore.A.dylib 0x000bc6f8 ucal_setAttribute + 96
9 libicucore.A.dylib 0x0000d650 ucal_open + 32
10 CoreFoundation 0x000a7968 _CFCalendarCreateUCalendar + 160
11 CoreFoundation 0x00029cde CFCalendarCreateWithIdentifier + 362
12 CoreFoundation 0x0008d128 _CFLogCString + 472
13 CoreFoundation 0x00029b52 _CFLogvEx + 166
14 CoreFoundation 0x0003d63e CFLog + 26
15 CoreFoundation 0x00015184 _CFAutoreleasePoolPop + 52
16 Foundation 0x0000422a NSPopAutoreleasePool + 2
17 Foundation 0x0000de16 -[_NSOperationInternal start] + 910
18 Foundation 0x0000da78 -[NSOperation start] + 16
19 Foundation 0x0007e5b4 _startOperations_block_invoke_2 + 40
20 libSystem.B.dylib 0x000d5c54 _dispatch_call_block_and_release + 12
21 libSystem.B.dylib 0x000d6a34 _dispatch_worker_thread2 + 120
22 libSystem.B.dylib 0x0007ad82 _pthread_wqthread + 258
23 libSystem.B.dylib 0x00073fcc start_wqthread + 0
Thread 4:
0 libSystem.B.dylib 0x00001f8e memcpy + 718
1 TestRaspLayer 0x00007718 _inline_memcpy_chk (_string.h:58)
2 TestRaspLayer 0x00007678 -[SERIALPort processRxBuffer] (SERIALPort.m:243)
3 CoreFoundation 0x0009f06c _invoking_ + 60
4 CoreFoundation 0x00032706 -[NSInvocation invoke] + 102
5 Foundation 0x0007eb50 -[NSInvocationOperation main] + 72
6 Foundation 0x0000dd14 -[_NSOperationInternal start] + 652
7 Foundation 0x0000da78 -[NSOperation start] + 16
8 Foundation 0x0007e5b4 _startOperations_block_invoke_2 + 40
9 libSystem.B.dylib 0x000d5c54 _dispatch_call_block_and_release + 12
10 libSystem.B.dylib 0x000d6a34 _dispatch_worker_thread2 + 120
11 libSystem.B.dylib 0x0007ad82 _pthread_wqthread + 258
12 libSystem.B.dylib 0x00073fcc start_wqthread + 0
Thread 3 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x0000007f r2: 0x00000077 r3: 0x80000001
r4: 0x0013fc50 r5: 0x0038003c r6: 0x0038012c r7: 0x0037ff70
r8: 0x00000000 r9: 0xffffffff r10: 0x0013fcb4 r11: 0x00000000
ip: 0x00000077 sp: 0x0037ff68 lr: 0x339fbe09 pc: 0x339b8bd0
cpsr: 0x50000030
答案 0 :(得分:0)
当设备断开连接或空闲时,您的应用会崩溃,还是仅在设备发送数据时才会发生崩溃?
答案 1 :(得分:0)
我认为
Thread 4:
0 libSystem.B.dylib 0x00001f8e memcpy + 718
1 TestRaspLayer 0x00007718 _inline_memcpy_chk (_string.h:58)
2 TestRaspLayer 0x00007678 -[SERIALPort processRxBuffer] (SERIALPort.m:243)
是应用程序崩溃的地方,问题可能来自SERIALPort类中的方法processRXBuffer。
仔细检查您的代码,您就会发现问题所在。