我看到偶爾崩潰報告中_WebTryThreadLock這樣的:WebTryThreadLock SEGV
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0xffffffffbbadbeef
Thread 5 Crashed:
0 WebCore 0x00005822 _WebTryThreadLock(bool) + 158
1 WebCore 0x0000576f WebThreadLock + 47
2 UIKit 0x001ae019 -[UIWebView dealloc] + 73
3 CoreFoundation 0x00006f7b -[NSObject(NSObject) release] + 31
4 Foo 0x0000c001 -[FooViewController dealloc] (FooViewController.m:653)
5 CoreFoundation 0x00006f7b -[NSObject(NSObject) release] + 31
6 CoreFoundation 0x0000b3c9 CFRelease + 69
7 CoreFoundation 0x0000a8df _CFAutoreleasePoolPop + 147
8 libSystem.B.dylib 0x000d6c04 _dispatch_worker_thread2 + 228
9 libSystem.B.dylib 0x0007b251 _pthread_wqthread + 265
或
Thread 1 Crashed:
0 WebCore 0x34c263c8 _WebTryThreadLock(bool) + 112
1 WebCore 0x34c281b1 WebThreadLock + 53
2 UIKit 0x35a3765f -[UITextView dealloc] + 31
3 CoreFoundation 0x30329c43 -[NSObject(NSObject) release] + 31
4 UIKit 0x358ad5f5 -[UIView(Hierarchy) removeFromSuperview] + 365
5 UIKit 0x359426cd -[UIScrollView removeFromSuperview] + 49
6 UIKit 0x35a352f1 -[UITextView removeFromSuperview] + 73
7 UIKit 0x358c0de3 -[UIView dealloc] + 155
8 CoreFoundation 0x30329c43 -[NSObject(NSObject) release] + 31
9 UIKit 0x3591900f -[UIViewController dealloc] + 175
10 Foo 0x0000c167 -[FooViewController dealloc] (FooViewController.m:646)
11 CoreFoundation 0x30329c43 -[NSObject(NSObject) release] + 31
12 CoreFoundation 0x3032a1a1 CFRelease + 69
13 CoreFoundation 0x3032cebb _CFAutoreleasePoolPop + 147
14 libdispatch.dylib 0x33d0b6a5 _dispatch_worker_thread2 + 373
15 libsystem_c.dylib 0x33e0a591 _pthread_wqthread + 265
我無法重現這在我自己的測試雖然,所以我不肯定是什麼觸發它。它絕對不會經常發生。當我嘗試修改主線程以外的線程的UIKit元素時,我已經在WebThreadLock中看到了崩潰的提及。
我認爲必須是這裏發生的事情,因爲_dispatch_worker_thread2告訴我這是GCD線程與UIApplicationMain線程之一。我必須在GCD線程上運行一些東西,在主線程放開它後保持FooViewController的狀態,我想在這個非主線程中發生的removeFromSuperview調用是觸發問題的原因。