New issue
Advanced search Search tips

Issue 821487 link

Starred by 2 users

Issue metadata

Status: ExternalDependency
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

SecTrustSettingsCopyCertificates leaks on macOS 10.13.3 (4172 leaks for 1,168,160 total leaked bytes)

Reported by polyd...@gmail.com, Mar 13 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7

Steps to reproduce the problem:
1. launch GeForceNOW beta for Mac on macOS 10.13.3
2. run leaks command "leaks GeForceNOW"
==> massive leaks from OSXKnownRootHelper

What is the expected behavior?
no leaks.

What went wrong?
CFRelease(cert_array) is missing from OSXKnownRootHelper().

chromium/src/net/cert/known_roots_mac.cc

 42   OSXKnownRootHelper() {
 43     crypto::GetMacSecurityServicesLock().AssertAcquired();
 44 
 45     CFArrayRef cert_array = NULL;
 46     OSStatus rv = SecTrustSettingsCopyCertificates(
 47         kSecTrustSettingsDomainSystem, &cert_array);
 48     if (rv != noErr) {
 49       LOG(ERROR) << "Unable to determine trusted roots; assuming all roots are "
 50                  << "trusted! Error " << rv;
 51       return;
 52     }
 53     base::ScopedCFTypeRef<CFArrayRef> scoped_array(cert_array);
 54     for (CFIndex i = 0, size = CFArrayGetCount(cert_array); i < size; ++i) {
 55       SecCertificateRef cert = reinterpret_cast<SecCertificateRef>(
 56           const_cast<void*>(CFArrayGetValueAtIndex(cert_array, i)));
 57       known_roots_.insert(x509_util::CalculateFingerprint256(cert));
 58     }
...    CFRelease(cert_array);  // <== this line is missing.
 59   }

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 64.0.3282.119  Channel: n/a
OS Version: OS X 10.13.3
Flash Version: 

the exact same code produce no leaks on the previous major release version of macOS 10.12.6. the same code started to show this leak on macOS 10.13.3 (didn't test on 10.13).
 

Comment 1 by mattm@chromium.org, Mar 13 2018

Components: -Blink>Network Internals>Network>Certificate
Status: ExternalDependency (was: Unconfirmed)
Summary: SecTrustSettingsCopyCertificates leaks on macOS 10.13.3 (4172 leaks for 1,168,160 total leaked bytes) (was: SecTrustSettingsCopyCertificates leaks (4172 leaks for 1,168,160 total leaked bytes))
The CFRelease isn't missing, the ScopedCFTypeRef on line 53 will release it.

It looks like Apple introduced leaks inside SecTrustSettingsCopyCertificates.
Cc: mattm@chromium.org
I'm not sure if this is strictly ExternalDependency either - OSXKnownRootHelper is a Leaky LazyInstance, so of course we'd leak on shutdown - we've explicitly annotated it as such.

matt: Do you think I'm missing something in the analysis? Otherwise, I'll close it :)

Comment 3 by polyd...@gmail.com, Mar 13 2018

oh, okay. my bad. sorry about that. if that's the case, this is a leak from SecTrustSettingsCopyCertificates as you mentioned.

Comment 4 by polyd...@gmail.com, Mar 13 2018

$ MallocStackLogging= /Applications/GeForceNOW.app/Contents/MacOS/GeForceNOW

$ leaks GeForceNOW
Process:         GeForceNOW [10127]
Path:            /Applications/GeForceNOW.app/Contents/MacOS/GeForceNOW
Load Address:    0x107a70000
Identifier:      com.nvidia.gfnpc.mall
Version:         1.8.0.26 (1.8.0.26)
Code Type:       X86-64
Parent Process:  bash [10095]

Date/Time:       2018-03-12 10:23:37.820 -0700
Launch Time:     2018-03-12 10:23:03.440 -0700
OS Version:      Mac OS X 10.13.3 (17D102)
Report Version:  7
Analysis Tool:   /usr/bin/leaks
----

leaks Report Version:  2.0
Process 10127: 68112 nodes malloced for 25187 KB
Process 10127: 4172 leaks for 1168160 total leaked bytes.
Leak: 0x7f8465c23290  size=16  zone: DefaultMallocZone_0x10858b000   NSDate  ObjC  CoreFoundation  2018-03-12 10:23:05 -0700
    Call stack: [thread 0x700008065000]: | thread_start | _pthread_body | _pthread_body | base::(anonymous namespace)::ThreadFunc(void*) | base::internal::SchedulerWorker::Thread::ThreadMain() | ...  | base::LazyInstance<net::(anonymous namespace)::OSXKnownRootHelper, base::internal::LeakyLazyInstanceTraits<net::(anonymous namespace)::OSXKnownRootHelper> >::Get() | SecTrustSettingsCopyCertificates | SecTrustEvaluate | SecTrustEvaluateIfNecessary | SecTrustGetVerifyTime | _dispatch_queue_barrier_sync_invoke_and_complete | _dispatch_client_callout | __SecTrustGetVerifyTime_block_invoke | +[__NSDate __new:] | __CFAllocateObject | class_createInstance | calloc | malloc_zone_calloc 
... 

Comment 5 by mattm@chromium.org, Mar 13 2018

ryan: the leaks are of various objc types allocated under SecTrustSettingsCopyCertificates, so it doesn't look related to the Leaky LazyInstance.

Comment 6 by polyd...@gmail.com, Mar 13 2018

GeForceNOW beta for Mac : https://download.nvidia.com/gfnpc/GeForceNOW-release.dmg

Sign in to add a comment