我運行從iOS開發人員中心下載的SampleFTPSample源代碼(iOS6.0 SDK,Xcode4.5)。 SampleFTPSampleiOS 6 EXC_BAD_ACCESS in SampleFTPSample代碼
的圖片,當我取回從FTPServer的列表,有時會得到EXC_BAD_ACCESS錯誤。我沒有修改代碼,我不知道爲什麼,我該如何修復它?
非常感謝。
我運行從iOS開發人員中心下載的SampleFTPSample源代碼(iOS6.0 SDK,Xcode4.5)。 SampleFTPSampleiOS 6 EXC_BAD_ACCESS in SampleFTPSample代碼
的圖片,當我取回從FTPServer的列表,有時會得到EXC_BAD_ACCESS錯誤。我沒有修改代碼,我不知道爲什麼,我該如何修復它?
非常感謝。
附加崩潰日誌
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
yeahh!我終於找到了解決辦法。主線程完成後,我調用了uialertview show。所以它現在不會崩潰。這是我的情況。所以沒有一個確切的答案,但你也可以應用這個 peterlawn。也許這對你也是有用的。 !
有沒有更好的方法來解決這個問題,因爲我需要在用戶使用應用程序時在後臺執行FTP連接,並且無法在主線程中顯示警報。 – o15a3d4l11s2
是的,爲此不需要任何警報。這就是爲什麼我在這個答案中告訴我這是我的例子。對於你來說,你可以在你的後臺線程不同的線程中執行你的應用程序崩潰的動作,並且在任務完成後立即關閉新線程 –
通過在創建流(使用CFReadStreamCreateWithFTPURL)後立即將kCFStreamPropertyFTPAttemptPersistentConnection屬性設置爲false來完成此操作。下面是可能的樣子:
success = [self.networkStream setProperty:(__bridge id) kCFBooleanFalse
forKey:(__bridge NSString *) kCFStreamPropertyFTPAttemptPersistentConnection
];
assert(success);
你可以把整個代碼放入回收列表中,讓我有想法嗎? – Dhaval
你能解釋一下這是什麼以及爲什麼它是必要的?這是新的ios6 – brianestey
它適用於我的情況..謝謝! –
- (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];
}
}
得到這個問題的任何解決方案? – Dhaval