Calling self.titleLabel within [UIButton titleRectForContentRect:] causes infinite loop

Originator:imarcelv
Number:rdar://51294267 Date Originated:
Status:Open Resolved:
Product:UIKit Product Version:12.2
Classification:Crash Reproducible:Always
 
Summary:
We noticed that when using self.titleLabel within UIButton's titleRectForContentRect: method, this will result in an infinite loop. We have to use the titleLabel property here though due to another bug in the iOS SDK. Nevertheless, using self.titleLabel here shouldn't result in an infinite loop and therefore a crash.

Steps to Reproduce:
Subclass UIButton, override titleRectForContentRect: method, add the super call, use self.titleLabel.numberOfLines for example. This will ultimately result in EXC_BAD_ACCESS (code=2, address=0x7ffee6c91ff0).

Expected Results:
Using self.titleLabel in -titleRectForContentRect: shouldn't cause an infinite loop.

Actual Results:
Using self.titleLabel in -titleRectForContentRect: causes an infinite loop.


Version/Build:
iOS 12.2

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!