kishikawakatsumi / UICKeyChainStore

UICKeyChainStore is a simple wrapper for Keychain on iOS, watchOS, tvOS and macOS. Makes using Keychain APIs as easy as NSUserDefaults.
http://kishikawakatsumi.com
MIT License
3.08k stars 383 forks source link

Crash when SecItemCopyMatching #155

Open Firerage opened 7 years ago

Firerage commented 7 years ago

I try to get password from UICKeyChainStore 2.1.0.This method

crash when SecItemCopyMatching

Device Information: iOS 10.3.3 iPhone6 Plus

appsailor commented 6 years ago

@kishikawakatsumi,

One of our apps is getting the following crash similar to this and its happening a lot. Here is the crash details. Any help will be much appreciated.

cheers, Aldrin

OS Version: 10.3.3 (14G60)

Device: iPhone 7

RAM Free: 1.1%

Disk Free: 91.9%

0. Crashed: com.apple.main-thread

0 libsystem_malloc.dylib 0x1814796d8 szone_malloc_should_clear + 4 1 libsystem_malloc.dylib 0x18147c4e8 malloc_zone_calloc + 168 2 libsystem_malloc.dylib 0x18147c41c calloc + 40 3 libobjc.A.dylib 0x180eb8160 class_createInstance + 76 4 libdispatch.dylib 0x181302a18 _os_object_alloc_realized + 40 5 libdispatch.dylib 0x181305540 dispatch_mach_msg_create + 80 6 libdispatch.dylib 0x181319148 _dispatch_mach_send_and_wait_for_reply + 1152 7 libdispatch.dylib 0x1813192e8 dispatch_mach_send_with_result_and_wait_for_reply + 56 8 libxpc.dylib 0x181540edc xpc_connection_send_message_with_reply_sync + 196 9 Security 0x182864e44 securityd_message_with_reply_sync + 200 10 Security 0x182865114 securityd_send_sync_and_do + 80 11 Security 0x18288ac88 __SecItemCopyMatching_block_invoke_2 + 212 12 Security 0x18288c730 SecItemAuthDoQuery_block_invoke + 304 13 Security 0x18288978c SecItemAuthDo + 1116 14 Security 0x18288a424 SecItemAuthDoQuery + 492 15 Security 0x18288aba8 SecItemCopyMatching_block_invoke + 116 16 Security 0x182888c3c SecOSStatusWith + 52 17 Security 0x18288aaec SecItemCopyMatching + 396 18 UICKeyChainStore 0x101758334 -[UICKeyChainStore dataForKey:error:] + 208 19 UICKeyChainStore 0x101757c08 -[UICKeyChainStore stringForKey:error:] + 40

kishikawakatsumi commented 6 years ago

@Firerage @appsailor Could you provide a reproduction case?

appsailor commented 6 years ago

@kishikawakatsumi - false alarm, there was an infinite loop issue that resulted in this crash on our side. So fixed it after lots of trial and errors to narrow down the problem area. All good for now. Thanks!

shanksGuo commented 5 years ago

@kishikawakatsumi @appsailor so, is this problem solved? I met a dead lock when multi thread situation, one thread execute SecItemCopyMatching and another execute SecItemAdd.

ninja342 commented 5 years ago

@shanksGuo we are facing with a similar problem can you explain how you detected deadlock and how did you fixed it?

shanksGuo commented 5 years ago

I can’t reproduce that, we met this problem when App Store review our App. Our solution is using dispatch_once because once is enough for us. For you, I guess you can use sync operation or serial queue.