Re: CoreFoundation object over-retained during finalization
Re: CoreFoundation object over-retained during finalization
- Subject: Re: CoreFoundation object over-retained during finalization
- From: "email@hidden" <email@hidden>
- Date: Sat, 12 Mar 2011 20:58:54 +0000
On 12 Mar 2011, at 20:06, David Riggle wrote:
> I've seen similar SecKeychain crashes whenever I put runtime code signing checks into my code. I suspect SecKeychain is not garbage collection safe. I've taken to doing the following to eliminate the crashes:
>
> [[NSGarbageCollector defaultCollector] disable];
>
> err = SecCodeCopySelf(...);
> err = SecCodeCopyStaticCode(...);
> err = SecRequirementCreateWithString(...);
> err = SecStaticCodeCheckValidity(...);
>
> CFRelease(...);
> CFRelease(...);
> CFRelease(...);
>
> [[NSGarbageCollector defaultCollector] enable];
>
> You might give that a try and see if it reduces the crash reports.
>
> Dave
>
Hmmm...
When thread 2 crashes like so...
===== start thread 2
Crashed Thread: 2 Dispatch queue: Garbage Collection Work Queue
Application Specific Information:
objc[4128]: garbage collection is ON
fatal resurrection error for garbage block 0x10bbcf0(SecKeychain[304]): over-retained during finalization, refcount = 1
===== end thread 2
... the thread 0 stack is as appended below.
Frame 34 indicates that the keychain core is being accessed. Coincidence?
TLS is used on the network comms and there is obvious interplay with the code signing infrastructure (the app is code signed).
I'm not sure that I can neatly bracket the problem with a disabled collector though as you suggest.
I am tempted to simply retain a permanent strong ref to my keychain object.
Perhaps that will stop this garbage collision.
Regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://www.mugginsoft.com
Thread 0: Dispatch queue: com.apple.main-thread
0 com.apple.security 0x9097aa84 bn_mul_add_words + 307
1 com.apple.security 0x9097a812 BN_from_montgomery + 299
2 com.apple.security 0x9097809b BN_mod_mul_montgomery + 131
3 com.apple.security 0x90977e95 BN_mod_exp_mont + 876
4 com.apple.security 0x90975d37 RSA_eay_public_decrypt + 351
5 com.apple.security 0x90975919 RSASigner::verify(void const*, unsigned long, void const*, unsigned long) + 407
6 com.apple.security 0x9097570b SignatureContext::final(Security::CssmData const&) + 107
7 com.apple.security 0x9097444a cssm_VerifyData(long, unsigned long long, cssm_context const*, cssm_data const*, unsigned int, unsigned int, cssm_data const*) + 148
8 com.apple.security 0x9097430a CSSM_VerifyData + 116
9 com.apple.security 0x90974278 AppleX509CLSession::verifyData(unsigned long long, Security::CssmData const&, Security::CssmData const&) + 54
10 com.apple.security 0x90974005 AppleX509CLSession::CertVerify(unsigned long long, Security::CssmData const&, Security::CssmData const*, cssm_field const*, unsigned int) + 1083
11 com.apple.security 0x90973b3b cssm_CertVerify(long, unsigned long long, cssm_data const*, cssm_data const*, cssm_field const*, unsigned int) + 100
12 com.apple.security 0x90973a26 CSSM_CL_CertVerify + 96
13 com.apple.security 0x909737d0 TPClItemInfo::verifyWithIssuer(TPCertInfo*, TPCertInfo*) const + 494
14 com.apple.security 0x9097346c TPCertGroup::findIssuerForCertOrCrl(TPClItemInfo const&, bool&) + 330
15 com.apple.security 0x90972164 TPCertGroup::buildCertGroup(TPClItemInfo const&, TPCertGroup*, cssm_dl_db_list const*, long, long, char const*, unsigned int, cssm_data const*, TPCertGroup&, TPCertGroup*, int, unsigned int, cssm_data const*, char const*, unsigned int, unsigned int, int&, int&, int&) + 1314
16 com.apple.security 0x90971be7 AppleTPSession::CertGroupConstructPriv(long, long, TPCertGroup&, cssm_dl_db_list const*, char const*, unsigned int, cssm_data const*, unsigned int, cssm_data const*, char const*, unsigned int, unsigned int, TPCertGroup&, int&, int&, int&, TPCertGroup&) + 201
17 com.apple.security 0x9096f5de AppleTPSession::CertGroupVerify(long, long, cssm_certgroup const&, cssm_tp_verify_context const*, cssm_tp_verify_context_result*) + 988
18 com.apple.security 0x9096f120 cssm_CertGroupVerify(long, long, long, cssm_certgroup const*, cssm_tp_verify_context const*, cssm_tp_verify_context_result*) + 85
19 com.apple.security 0x9096eedf CSSM_TP_CertGroupVerify + 79
20 com.apple.security 0x9096ec96 Security::CssmClient::TPImpl::certGroupVerify(Security::CertGroup const&, Security::TPVerifyContext const&, Security::TPVerifyResult*) + 148
21 com.apple.security 0x90a0965d Security::KeychainCore::Trust::evaluate(bool) + 2473
22 com.apple.security 0x909611db SecTrustEvaluate + 91
23 com.apple.security 0x909b96b3 Security::CodeSigning::SecStaticCode::verifySignature() + 865
24 com.apple.security 0x909b984c Security::CodeSigning::SecStaticCode::validateDirectory() + 78
25 com.apple.security 0x909b9e3a Security::CodeSigning::SecStaticCode::defaultDesignatedRequirement() + 48
26 com.apple.security 0x909ba099 Security::CodeSigning::SecStaticCode::designatedRequirement() + 45
27 com.apple.security 0x909b3c54 SecCodeCopyDesignatedRequirement + 47
28 com.apple.security 0x90a8ed33 Security::OSXVerifier::OSXVerifier(Security::OSXCode*) + 343
29 com.apple.security 0x90a0aa4d Security::KeychainCore::TrustedApplication::TrustedApplication() + 105
30 com.apple.security 0x909d472c Security::KeychainCore::Access::Access(std::string const&) + 130
31 com.apple.security 0x90a15dab impExpImportKeyCommon + 2730
32 com.apple.security 0x90a16372 impExpImportRawKey + 552
33 com.apple.security 0x90a0db2b Security::KeychainCore::SecImportRep::importRep(OpaqueSecKeychainRef*, long, unsigned int, SecKeyImportExportParameters const*, ImpPrivKeyImportState&, __CFArray*) + 679
34 com.apple.security 0x90a0d539 SecKeychainItemImport + 1045
35 ...ginsoft.kosmictaskframework 0x001655f3 BindSocket + 13446
36 ...ginsoft.kosmictaskframework 0x00164eb7 BindSocket + 11594
37 ...ginsoft.kosmictaskframework 0x00164b43 BindSocket + 10710
38 ...ginsoft.kosmictaskframework 0x001649c5 BindSocket + 10328
39 com.mugginsoft.kosmictask 0x00006924 start + 15088
40 com.mugginsoft.kosmictask 0x0000a18d start + 29529
41 com.apple.Foundation 0x948484df _nsnote_callback + 176
42 com.apple.CoreFoundation 0x94ed4793 __CFXNotificationPost + 947
43 com.apple.CoreFoundation 0x94ed419a _CFXNotificationPostNotification + 186
44 com.apple.Foundation 0x9483d384 -[NSNotificationCenter postNotificationName:object:userInfo:] + 128
45 com.apple.Foundation 0x9484a789 -[NSNotificationCenter postNotificationName:object:] + 56
46 com.apple.AppKit 0x92c8c422 -[NSApplication _postDidFinishNotification] + 125
47 com.apple.AppKit 0x92c8c332 -[NSApplication _sendFinishLaunchingNotification] + 74
48 com.apple.AppKit 0x92de34ed -[NSApplication(NSAppleEventHandling) _handleAEOpen:] + 274
49 com.apple.AppKit 0x92de310d -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 101
50 com.apple.Foundation 0x9487d7a4 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 511
51 com.apple.Foundation 0x9487d568 _NSAppleEventManagerGenericHandler + 228
52 com.apple.AE 0x98e04f58 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned long, unsigned char*) + 166
53 com.apple.AE 0x98e04e57 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 43
54 com.apple.AE 0x98e04d61 aeProcessAppleEvent + 197
55 com.apple.HIToolbox 0x926a9389 AEProcessAppleEvent + 50
56 com.apple.AppKit 0x92c5c9ca _DPSNextEvent + 1420
57 com.apple.AppKit 0x92c5bfce -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
58 com.apple.AppKit 0x92c1e247 -[NSApplication run] + 821
59 com.apple.AppKit 0x92c162d9 NSApplicationMain + 574
60 com.mugginsoft.kosmictask 0x00002e69 start + 53
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden