KVO crash on UITextField initWithFrame

≯℡__Kan透↙ 提交于 2020-01-14 03:25:07

问题


A customer of my app sent me this strange crash report and I cannot figure out how this could ever crash. I cannot reproduce the problem myself, so am reliant on the crash report.

It crashes on the following very simple line of code:

UITextField *value = [[UITextField alloc] initWithFrame:frame];

The crash seems to be related to key-value-observing (KVO), but I am not doing anything with that here; it's a simply constructor! The only possibility I could see, is that another thread is writing to a dealloc'ed object that happens to have the same memory address as an object that is created by the initWithFrame:. But in the crash report, all other threads are quiet.

I have found other similar questions, but none of them have an answer.

Any ideas?

Here are the relevant parts from the crash report:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000010
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x0000000181981b90 objc_msgSend + 16
1   Foundation                      0x0000000182bf2454 -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:] + 324
2   QuartzCore                      0x0000000184deb11c CA::Layer::set_delegate(objc_object*) + 72
3   UIKit                           0x0000000187456f40 -[UIView _createLayerWithFrame:] + 580
4   UIKit                           0x0000000187456a00 UIViewCommonInitWithFrame + 688
5   UIKit                           0x00000001874566f0 -[UIView initWithFrame:] + 140
6   UIKit                           0x000000018745dfb0 -[UILabel initWithFrame:] + 48
7   UIKit                           0x0000000187542064 -[UITextField createTextLabelWithTextColor:] + 76
8   UIKit                           0x0000000187541c30 -[UITextField initWithFrame:] + 416
9   Flyskyhy                        0x00000001000e1f68 -[ElementView doInitWithUnit:] (ElementView.m:178)

来源:https://stackoverflow.com/questions/36597727/kvo-crash-on-uitextfield-initwithframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!