Certain string/pattern pairs cause [NSString isLike:] to hang, spinning at 100% cpu.

Number:rdar://31112184 Date Originated:17 Mar 2017
Status:Closed Resolved:
Product:macOS + SDK Product Version:10.12.3
Classification:Hang/Freeze Reproducible:100%
isLike: never returns for magic strings/patterns

Steps to Reproduce:
With Xcode 8.1 or 8.3 installed, enter the following at a command prompt:

echo 'import Foundation ; if true {  let pattern="*expir*" ; let name="resetAccountPasswordWithCancellable" ; print ("Starting match"); print ((name.lowercased() as NSString).isLike(pattern)) }' | swift

Expected Results:
Returns instantly with pattern match result.

Actual Results:
Hangs indefinitely.

Sierra / El Capitan


There are no plans to address this based on the following:

You should not use -[NSString isLike]; use -[NSString rangeOfString:…] or one of its convenience wrappers such as -[NSString localizedCaseInsensitiveContainsString:], or if you really need wildcard behavior NSRegularExpression.

By stevenkramer1 at March 22, 2017, 8:42 p.m. (reply...)

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!