任何人都知道为什么有时会崩溃?我很难过这个。我猜它在100或者类似的东西中崩溃了一次。
// from header file
struct _PTP_IP_Packet_INIT_EVENT_ACK {
uint32_t ptpIPPacketLength;
uint32_t ptpIPType;
};
typedef struct _PTP_IP_Packet_INIT_EVENT_ACK PTP_IP_Packet_INIT_EVENT_ACK;
#define PTP_IP_PacketLength_INIT_EVENT_ACK (2*sizeof(uint32_t))
崩溃在最后一行:
PTP_IP_Packet_INIT_EVENT_ACK eventack;
PTP_CNT_INIT(eventack);
len = [self.myWorker.eventInputStream read:(unsigned char*)&eventack maxLength:PTP_IP_PacketLength_INIT_EVENT_ACK];
崩溃数据:
#24
EXC_BREAKPOINT 0x0000000184045750
Crashed: PTPWork-192.168.1.1
0 CoreFoundation 0x184045750 CFHash + 256
1 CoreFoundation 0x184046c1c CFBasicHashGetCountOfKey + 960
2 CoreFoundation 0x184046810 CFSetContainsValue + 152
3 CoreFoundation 0x18407644c CFRunLoopRemoveSource + 236
4 CFNetwork 0x183b68fcc SocketStream::read(__CFReadStream*, unsigned char*, long, CFStreamError*, unsigned char*) + 520
5 CoreFoundation 0x184072c88 CFReadStreamRead + 520
6 Photobooth 0x1001348a0 -[PTPCamera initializeEventStreams] (PTPCamera.m:188)
7 Photobooth 0x100134398 -[PTPCamera initializePTP] (PTPCamera.m:127)
8 Photobooth 0x1001084b0 -[PTPWorker setState:] (PTPWorker.m:333)
9 Photobooth 0x100107b8c -[PTPWorker main] (PTPWorker.m:222)
10 Foundation 0x18505e308 __NSThread__main__ + 1072
11 libsystem_pthread.dylib 0x195babdc8 _pthread_body + 164
12 libsystem_pthread.dylib 0x195babd24 _pthread_body + 158
13 libsystem_pthread.dylib 0x195ba8ef8 thread_start + 4
答案 0 :(得分:4)
EXC_BREAKPOINT在这种上下文中通常意味着抛出了一个NSException,这是调试器中断的一个方便的地方。
self.myWorker.eventInputStream出错的两个最有可能的原因(不相互排斥)是
这在NSThread中崩溃使第二个选项成为可能。你报告这种情况发生在" 1次100或类似的事情"使第二个选项成为一个虚拟的确定性。
为了确保,在主线程上使用self.myWorker.eventInputStream放置所有内容。如果崩溃立即完全消失,正如预期的那样,那么你需要弄清楚如何正确锁定对流的访问,这样无论争议问题在这里消失了。祝你好运!