IOS 6 EXC_BAD_ACCESS in SampleFTPSample code

I am running the SampleFTPSample source code (iOS6.0 SDK, Xcode4.5), which is downloaded from the iOS Developer Center. SampleFTPSample

as images, when i got the list from ftpServer, sometimes you get EXC_BAD_ACCESS error. I have not changed the code, I do not know why, and how can I fix it?

Many thanks.

EXC_BAD_ACCESS Fig. 1EXC_BAD_ACCESS Fig. 2EXC_BAD_ACCESS Fig. 3

+3
ios6 ftp-client
source share
4 answers

do this by setting the kCFStreamPropertyFTPAttemptPersistentConnection property to false immediately after creating the stream (using CFReadStreamCreateWithFTPURL). Here's what it looks like:

success = [self.networkStream setProperty:(__bridge id) kCFBooleanFalse forKey:(__bridge NSString *) kCFStreamPropertyFTPAttemptPersistentConnection ]; assert(success); 
+8
source share

Crash log added

 Date/Time: 2012-09-27 14:15:16.911 +0800 OS Version: iOS 6.0 (10A403) Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00000030 Crashed Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 CFNetwork 0x3614ad44 <redacted> + 64 1 CFNetwork 0x3614aeaa <redacted> + 222 2 CFNetwork 0x3614a84c <redacted> + 108 3 CFNetwork 0x36171cb2 <redacted> + 26 4 CFNetwork 0x36122000 <redacted> + 316 5 CFNetwork 0x361482ee <redacted> + 3414 6 CFNetwork 0x361b7e26 <redacted> + 38 7 CFNetwork 0x361b7f16 <redacted> + 6 8 CFNetwork 0x361b91b2 <redacted> + 42 9 CFNetwork 0x361b7920 <redacted> + 36 10 CoreFoundation 0x32e6d3f4 <redacted> + 72 11 CoreFoundation 0x32e882f6 CFReadStreamOpen + 86 12 FTPSample 0x0009c324 0x96000 + 25380 13 FTPSample 0x0009cdee 0x96000 + 28142 14 UIKit 0x35b3d0a8 -[UIApplication sendAction:to:from:forEvent:] + 68 15 UIKit 0x35b3d130 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 116 16 UIKit 0x35b3d0a8 -[UIApplication sendAction:to:from:forEvent:] + 68 17 UIKit 0x35b3d05a -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26 18 UIKit 0x35b3d038 -[UIControl sendAction:to:forEvent:] + 40 19 UIKit 0x35b3c8ee -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 498 20 UIKit 0x35b3cde4 -[UIControl touchesEnded:withEvent:] + 484 21 UIKit 0x35a655f4 -[UIWindow _sendTouchesForEvent:] + 520 22 UIKit 0x35a52804 -[UIApplication sendEvent:] + 376 23 UIKit 0x35a5211e _UIApplicationHandleEvent + 6150 24 GraphicsServices 0x33bca5a0 _PurpleEventCallback + 588 25 GraphicsServices 0x33bca1ce PurpleEventCallback + 30 26 CoreFoundation 0x32eef170 <redacted> + 32 27 CoreFoundation 0x32eef112 <redacted> + 134 28 CoreFoundation 0x32eedf94 <redacted> + 1380 29 CoreFoundation 0x32e60eb8 CFRunLoopRunSpecific + 352 30 CoreFoundation 0x32e60d44 CFRunLoopRunInMode + 100 31 GraphicsServices 0x33bc92e6 GSEventRunModal + 70 32 UIKit 0x35aa62fc UIApplicationMain + 1116 33 FTPSample 0x00097bc8 0x96000 + 7112 34 FTPSample 0x00097364 0x96000 + 4964 Thread 1: 0 libsystem_kernel.dylib 0x31be9d98 __workq_kernreturn + 8 1 libsystem_c.dylib 0x36f9bcf6 <redacted> + 14 2 libsystem_c.dylib 0x36f9ba12 <redacted> + 362 3 libsystem_c.dylib 0x36f9b8a0 start_wqthread + 4 Thread 2 name: Dispatch queue: com.apple.libdispatch-manager Thread 2: 0 libsystem_kernel.dylib 0x31bd9648 kevent64 + 24 1 libdispatch.dylib 0x373024ec _dispatch_mgr_invoke + 792 2 libdispatch.dylib 0x372f4df4 _dispatch_mgr_thread$VARIANT$up + 32 Thread 3: 0 libsystem_kernel.dylib 0x31be9d98 __workq_kernreturn + 8 1 libsystem_c.dylib 0x36f9bcf6 <redacted> + 14 2 libsystem_c.dylib 0x36f9ba12 <redacted> + 362 3 libsystem_c.dylib 0x36f9b8a0 start_wqthread + 4 Thread 4 name: WebThread Thread 4: 0 libsystem_kernel.dylib 0x31bd8eb4 mach_msg_trap + 20 1 libsystem_kernel.dylib 0x31bd9048 mach_msg + 36 2 CoreFoundation 0x32eef040 <redacted> + 124 3 CoreFoundation 0x32eedd9e <redacted> + 878 4 CoreFoundation 0x32e60eb8 CFRunLoopRunSpecific + 352 5 CoreFoundation 0x32e60d44 CFRunLoopRunInMode + 100 6 WebCore 0x33c44a70 <redacted> + 440 7 libsystem_c.dylib 0x36fa630e <redacted> + 306 8 libsystem_c.dylib 0x36fa61d4 thread_start + 4 Thread 5: 0 libsystem_kernel.dylib 0x31be9d98 __workq_kernreturn + 8 1 libsystem_c.dylib 0x36f9bcf6 <redacted> + 14 2 libsystem_c.dylib 0x36f9ba12 <redacted> + 362 3 libsystem_c.dylib 0x36f9b8a0 start_wqthread + 4 Thread 6 name: com.apple.CFSocket.private Thread 6: 0 libsystem_kernel.dylib 0x31be9594 __select + 20 1 CoreFoundation 0x32ef31f2 <redacted> + 674 2 libsystem_c.dylib 0x36fa630e <redacted> + 306 3 libsystem_c.dylib 0x36fa61d4 thread_start + 4 Thread 7: 0 libsystem_kernel.dylib 0x31be9d98 __workq_kernreturn + 8 1 libsystem_c.dylib 0x36f9bcf6 <redacted> + 14 2 libsystem_c.dylib 0x36f9ba12 <redacted> + 362 3 libsystem_c.dylib 0x36f9b8a0 start_wqthread + 4 Thread 0 crashed with ARM Thread State (32-bit): r0: 0x00000007 r1: 0x1cddeef8 r2: 0x1cddeef8 r3: 0x00000004 r4: 0x00000000 r5: 0x1cdc8c90 r6: 0x00000007 r7: 0x2fd69554 r8: 0x0000000d r9: 0x000bc4b0 r10: 0x1cddbf70 r11: 0x1cddeef0 ip: 0x3abff970 sp: 0x2fd69524 lr: 0x3614ad3f pc: 0x3614ad44 cpsr: 0x60000030 
+1
source share

Yeahh !! I finally got a solution. I started uialertview show after the main thread shuts down. So this is not a failure now. This is in my case. Therefore, you do not have an exact answer, but you can also apply this peterlawn. Maybe it will be useful to you too. !!

+1
source share
 - (void)_startReceive:(NSString*) urlPath { BOOL success; NSURL * url; CFReadStreamRef ftpStream; assert(self.networkStream == nil); // don't tap receive twice in a row! // First get and check the URL. if(urlPath != nil) { ...url = FTP_URL here... } success = (url != nil); // If the URL is bogus, let the user know. Otherwise kick off the connection. if ( ! success) { [self _updateStatus:@"Invalid URL"]; } else { // Create the mutable data into which we will receive the listing. self.listData = [NSMutableData data]; assert(self.listData != nil); // Open a CFFTPStream for the URL. ftpStream = CFReadStreamCreateWithFTPURL(NULL, (__bridge CFURLRef) url); assert(ftpStream != NULL); self.networkStream = (__bridge NSInputStream *) ftpStream; success = [self.networkStream setProperty:(__bridge id) kCFBooleanFalse forKey:(__bridge NSString *) kCFStreamPropertyFTPAttemptPersistentConnection ]; assert(success); self.networkStream.delegate = self; [self.networkStream scheduleInRunLoop:[NSRunLoop currentRunLoop]forMode:NSDefaultRunLoopMode]; [self.networkStream open]; // Have to release ftpStream to balance out the create. self.networkStream // has retained this for our persistent use. CFRelease(ftpStream); // Tell the UI we're receiving. [self _receiveDidStart]; } 

}

0
source share

All Articles