Bug 194178

Summary: Leak of NSArray (4.25 Kbytes) in com.apple.WebKit.WebContent running WebKit layout tests on iOS Simulator
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: Tools / TestsAssignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, lforschler, mmaxfield, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=194761
Attachments:
Description Flags
Patch v1
none
Patch v2 none

David Kilzer (:ddkilzer)
Reported 2019-02-01 16:18:27 PST
Leak of NSArray (4.25 Kbytes) in com.apple.WebKit.WebContent running WebKit layout tests on iOS Simulator. NOTE: Requires patch in Bug 193772 to gather leaks for the com.apple.WebKit.WebContent.Development process. STACK OF 664 INSTANCES OF 'ROOT LEAK: <NSArray>': [thread 0x10f76c5c0]: 28 libdyld.dylib 0x10c003575 start + 1 27 com.apple.WebKit.WebContent 0x10854f3e5 invocation function for block in WebKit::XPCServiceEventHandler(NSObject<OS_xpc_object>*) + 0 XPCServiceMain.mm:46 26 com.apple.WebKit.WebContent 0x10854f268 WebKit::XPCServiceMain(int, char const**) + 403 XPCServiceMain.mm:157 25 libxpc.dylib 0x10c31cc75 xpc_main + 143 24 libxpc.dylib 0x10c31a7ca _xpc_objc_main + 460 23 com.apple.Foundation 0x108608522 -[NSRunLoop(NSRunLoop) run] + 76 22 com.apple.Foundation 0x1086083b2 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 277 21 com.apple.CoreFoundation 0x10a643e51 CFRunLoopRunSpecific + 625 20 com.apple.CoreFoundation 0x10a64467f __CFRunLoopRun + 1263 19 com.apple.CoreFoundation 0x10a649fd3 __CFRunLoopDoSources0 + 243 18 com.apple.CoreFoundation 0x10a64a761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 17 JavaScriptCore 0x3100d92a2 WTF::RunLoop::performWork(void*) + 34 RunLoopCF.cpp:39 16 JavaScriptCore 0x3100d9017 WTF::RunLoop::performWork() + 231 Function.h:56 15 com.apple.WebKit 0x108b98894 IPC::Connection::dispatchOneIncomingMessage() + 180 Connection.cpp:1074 14 com.apple.WebKit 0x108b95262 IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >) + 108 memory:2567 13 com.apple.WebKit 0x108e78ae2 WebKit::WebProcess::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 28 WebProcess.cpp:677 12 com.apple.WebKit 0x108ba2b03 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 127 MessageReceiverMap.cpp:0 11 com.apple.WebKit 0x108f4d7f4 WebKit::WebPage::didReceiveWebPageMessage(IPC::Connection&, IPC::Decoder&) + 17292 tuple:170 10 com.apple.WebKit 0x108f36db8 WebKit::WebPage::postInjectedBundleMessage(WTF::String const&, WebKit::UserData const&) + 78 utility:896 9 com.apple.WebKit 0x108e9d299 WebKit::InjectedBundleClient::didReceiveMessageToPage(WebKit::InjectedBundle&, WebKit::WebPage&, WTF::String const&, API::Object*) + 179 RefPtr.h:43 8 WebKitTestRunnerInjectedBundle 0x321d850ec WTR::InjectedBundle::didReceiveMessageToPage(OpaqueWKBundlePage const*, OpaqueWKString const*, void const*) + 1370 InjectedBundle.cpp:0 7 WebKitTestRunnerInjectedBundle 0x321d8897d WTR::InjectedBundlePage::resetAfterTest() + 95 InjectedBundlePage.cpp:447 6 WebKitTestRunnerInjectedBundle 0x321d819ad WTR::uninstallFakeHelvetica() + 532 ActivateFontsCocoa.mm:0 5 com.apple.CoreText 0x10d7ce946 CTFontManagerUnregisterFontsForURLs + 478 4 com.apple.CoreFoundation 0x10a632c65 +[__NSSingleObjectArrayI __new::] + 21 3 com.apple.CoreFoundation 0x10a704d11 __CFAllocateObject + 17 2 libobjc.A.dylib 0x109be1faf class_createInstance + 73 1 libsystem_malloc.dylib 0x10c26a67d calloc + 30 0 libsystem_malloc.dylib 0x10c26a015 malloc_zone_calloc + 139 ==== 15037 (2.16M) << TOTAL >> ---- 28 (4.25K) ROOT LEAK: <NSArray 0x7ff65cc0e6c0> [16] 27 (4.23K) __strong _object --> <CFError 0x7ff65cc14880> [48] 26 (4.19K) _userInfo --> <CFDictionary 0x7ff65cc148b0> [64] 24 (4.09K) <CFDictionary (Value Storage) 0x7ff65cc0fcc0> [32] 22 (4.00K) <NSMutableArray 0x7ff65cc14010> [48] 21 (3.95K) <NSMutableArray (Storage) 0x7ff65cc14850> [48] 4 (800 bytes) <NSURL 0x7ff65cc05bc0> [96] 2 (400 bytes) <_FileCache 0x7ff65cc0bf50> [336] 1 (64 bytes) <CFString 0x7ff65cc05ce0> [64] 1 (304 bytes) _clients --> <CFString 0x7ff65cc0aad0> [304] 4 (800 bytes) <NSURL 0x7ff65cc093f0> [96] 2 (400 bytes) <_FileCache 0x7ff65cc10e80> [336] 1 (64 bytes) <CFString 0x7ff65cc0f320> [64] 1 (304 bytes) _clients --> <CFString 0x7ff65cc0d7b0> [304] 4 (800 bytes) <NSURL 0x7ff65cc11450> [96] 2 (400 bytes) <_FileCache 0x7ff65cc11300> [336] 1 (64 bytes) <CFString 0x7ff65cc0fe90> [64] 1 (304 bytes) _clients --> <CFString 0x7ff65cc092c0> [304] 4 (800 bytes) <NSURL 0x7ff65cc12e20> [96] 2 (400 bytes) <_FileCache 0x7ff65cc12ba0> [336] 1 (64 bytes) <CFString 0x7ff65cc0bc90> [64] 1 (304 bytes) _clients --> <CFString 0x7ff65cc12cf0> [304] 4 (800 bytes) <NSURL 0x7ff65cc13450> [96] 2 (400 bytes) <_FileCache 0x7ff65cc13190> [336] 1 (64 bytes) <CFString 0x7ff65cc132e0> [64] 1 (304 bytes) _clients --> <CFString 0x7ff65cc13320> [304] 1 (64 bytes) <CFString 0x7ff65cc15200> [64] 1 (32 bytes) <CFDictionary (Key Storage) 0x7ff65cc0c300> [32]
Attachments
Patch v1 (1.56 KB, patch)
2019-02-01 16:22 PST, David Kilzer (:ddkilzer)
no flags
Patch v2 (1.62 KB, patch)
2019-02-01 22:16 PST, David Kilzer (:ddkilzer)
no flags
David Kilzer (:ddkilzer)
Comment 1 2019-02-01 16:18:34 PST
David Kilzer (:ddkilzer)
Comment 2 2019-02-01 16:22:26 PST
Created attachment 360923 [details] Patch v1
Darin Adler
Comment 3 2019-02-01 20:21:58 PST
Comment on attachment 360923 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=360923&action=review > Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:163 > CFArrayRef errors = nullptr; > CTFontManagerUnregisterFontsForURLs(static_cast<CFArrayRef>(fontsToRemove), kCTFontManagerScopeProcess, &errors); > + if (errors) { > + for (id error in (__bridge NSArray *)errors) > + NSLog(@"%@", (__bridge CFErrorRef)error); > + CFRelease(errors); > + } A better fix is to get rid of the "errors" local variable, and pass "nullptr" instead of "&errors" to CTFontManagerUnregisterFontsForURLs. Then there is no need for CFRelease. CTFontManagerUnregisterFontsForURLs won't generate an array of errors if we don’t pass a pointer to a place to put the CFArrayRef. Also, we should not land that logging code.
David Kilzer (:ddkilzer)
Comment 4 2019-02-01 22:15:36 PST
Comment on attachment 360923 [details] Patch v1 View in context: https://bugs.webkit.org/attachment.cgi?id=360923&action=review >> Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:163 >> + } > > A better fix is to get rid of the "errors" local variable, and pass "nullptr" instead of "&errors" to CTFontManagerUnregisterFontsForURLs. Then there is no need for CFRelease. CTFontManagerUnregisterFontsForURLs won't generate an array of errors if we don’t pass a pointer to a place to put the CFArrayRef. > > Also, we should not land that logging code. Yep, I had assumed that since Myles originally added the `errors` variable that we cared about the errors returned from CTFontManagerUnregisterFontsForURLs(). Easy enough to fix.
David Kilzer (:ddkilzer)
Comment 5 2019-02-01 22:16:03 PST
Created attachment 360964 [details] Patch v2
WebKit Commit Bot
Comment 6 2019-02-02 12:20:41 PST
Comment on attachment 360964 [details] Patch v2 Clearing flags on attachment: 360964 Committed r240900: <https://trac.webkit.org/changeset/240900>
WebKit Commit Bot
Comment 7 2019-02-02 12:20:43 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.