objective c - EXC_BAD_ACCESS with NSStreamEventHasBytesAvailable -
This is a very deceptive error, because even if I send and receive the same data then Sometimes it happens, sometimes it does not happen.
I am getting a stream through NSInputStream and I use standard code to read bytes received in that stream and pass them to another method like:
- (zero) stream: (NSStream *) aStream handleEvent: (NSStreamEvent) eventCode {switch (eventCode) {case NSStreamEventHasBytes available: {NSMutableData * data = [[NSMutableData alloc] init]; Uint8_t buf [1024]; NSInteger length = 0; Length = [(NSInputStream *) read aStream: Buff Maxelbag: 1024]; If (length> gt; 0) {[data edaybets: length of the bff: length]; [Self. Delegate doSomethingWithTheData: data]; } And {nslog (@ "no buffer!"); } break; } ...
Occasionally when the stream is starting to me, a EXC_BAD_ACCESS (code = 1, address = 0x8)
error for line
Length = [(NSInputStream *) aStream Reading: Buff MaxLabel: 1024];
I can not see what is the reason for this problem because aStream is never equal to zero and so what I have read inside it before it can never be canceled It is my understanding that it is written: MaxLtml gives an NSINtegae that will then be stored in length. The only issue I can think of will be with data present in the stream, but I have no way to test this data unless I can read it, which then leads to a vicious cycle.
Any thoughts?
Edit
This is a full stack trace:
(lldb) bt * thread # 1: tid = 0x2395e, 0x35b1d620 libsystem_kernel.dylib`syscall_thread_switch + 8, queue = 'com.apple.main thread' * frame # 0: 0x35b1d620 libsystem_kernel.dylib`syscall_thread_switch + 8 frame # 1: 0x35baa502 libsystem_platform.dylib`_os_lock_handoff_lock_slow + 78 Frame # 2: 0x35b57e14 libsystem_malloc .illib `szone_malloc_should_clear + 56 frame # 3: 0x35b5b400 libsystem_malloc.dylib`malloc_zone_calloc + 92 Frame # 4: 0x35b5b392 libsystem_malloc.dylib` calloc + 50 Frame # 5: 0x354f3410 libobjc.A.dylib_class_createInstance + 40 Frame # 6: 0x27e42aa0 CoreFoundation `__CFAllocateObject2 + 12 Frame # 7: 0x27d5b760 Core Foreignation '[__ NSARI __a NUUE :::] + 20 Frame # 8: 0x27d58d84 Corephone dation` - [__ NSPlaceholderArray initWithObjects: Count:] 136 Frame # 9: 0x27d5973c CoreFoundation` [NSArray initWithArray: border: copyItems:] 276 frame # 10: 0x27d59610 CoreFoundation` + [NSArray arrayWithArray:] + 72 frame # 11: 0x2b5b6bba UIKit- [UIViewController _traitCollectionForChildEnvironment:] + 26 frame # 12: 0x2b2d76d8 UIKit`__45- [UIView (hierarchy) _postMovedFromSuperview:] _ block_invoke + 216 frame # 13: 0x2b2d758c UIKit` - [UIView (hierarchy) _postMovedFromSuperview:] 428 frame # 14: 0x2b2d6458 UIKit`- [delete the UIView (hierarchy) View Reviewview] + 404 Frame # 15: 0x27d8d9bc Corfoundation` [[NSARRA ObjectPaper M. Selection:] + 196 frame # 16: 0x2b3aa814 UIKit`- [UITableViewReloadData] + 1304 Frame # 17: 0x0009d524MyTestApp` - Streaming in [Streaming VIPU controller peer disconnected] (self = 0x15ead880, _cmd = 0x000ed1d8) + 280 VIPU Controller 9: 950 frame # 18: 0x000e48e2 matestops`__34- [main view controller disconnected] _block_win (.bloca_discriptor = 0x15e8f970) + 426 manview controller. M 1271 Frame # 19: 0x0025 9 AAI libdispatch.dylib`_dispatch_call_block_and_release + 10 frame # 20: 0x00259ad6 libdispatch.dylib`_dispatch_client_callout + 22 frame # 21: 0x0025d4f6 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 810 frame # 22: 0x27e02be8 CoreFoundation `__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8 Frame # 23: 0x27e012e8 CoreFoundation`__CFRunLoopRun + 1512 Frame # 24: 0x27d4f620 CoreFoundation`CFRunLoopRunSpecific + 476 Frame # 25: 0x27d4f432 CoreFoundation`CFRunLoopRunInMode + 106 Frame # 26: 0x2f0fe0a8 GraphicsServices`GSEventRunModal + 136 Frame # 27: 0x2b33a358 UIKit `UIApplicationMain + 1440 frame # 28: MyTestApp`main 0x000d18bc (argc = 1, argv = 0x0023aadc) + 116 at main.m: 16
Comments
Post a Comment