Context:
Flaky leak in WebAuthFlowTest:
09:05:30 memcheck_analyze.py [ERROR] Command:
Leak_DefinitelyLost
14,249 (8 direct, 14,241 indirect) bytes in 1 blocks are definitely lost in loss record 34,768 of 35,169
operator new(unsigned long) (m_replacemalloc/vg_replace_malloc.c:1074)
SSLManager::SSLManager(NavigationControllerImpl*) (content/browser/ssl/ssl_manager.cc:84)
NavigationControllerImpl::NavigationControllerImpl(WebContentsImpl*, content::BrowserContext*, SessionStorageNamespaceImpl*) (content/browser/web_contents/navigation_controller_impl.cc:186)
WebContentsImpl::WebContentsImpl(content::BrowserContext*, content::SiteInstance*, int, WebContentsImpl const*, WebContentsImpl*, SessionStorageNamespaceImpl*) (content/browser/web_contents/web_contents_impl.cc:294)
content::TestWebContents::TestWebContents(content::BrowserContext*, content::SiteInstance*) (content/browser/web_contents/test_web_contents.cc:34)
content::WebContentsTester::CreateTestWebContents(content::BrowserContext*, content::SiteInstance*) (content/test/web_contents_tester.cc:63)
(anonymous namespace)::MockWebAuthFlow::CreateWebContents() (chrome/browser/extensions/api/identity/web_auth_flow_unittest.cc:62)
extensions::WebAuthFlow::Start() (chrome/browser/extensions/api/identity/web_auth_flow.cc:82)
WebAuthFlowTest_SilentRedirectToChromiumAppUrl_Test::TestBody() (chrome/browser/extensions/api/identity/web_auth_flow_unittest.cc:140)
Object Containment Hierarchy (indentation implies containment).
WebAuthFlow
- WebContentsImpl |contents_|
- NavigationControllerImpl
- SSLManager
- SSLPolicy* (LEAKED)
SSLManager deletes the SSLPolicy in its destructor, but the SSLManager is not being destructed.
~WebAuthFlow() calls MessageLoop::DeleteSoon(contents_).
WebAuthFlowTest inherits from ChromeRenderViewHostTestHarness whose TearDown eventually calls MessageLoop::RunAllPending().
Issue: MessageLoop::RunAllPending() is called before ~WebAuthFlow(), i.e. before a task is posted to the MessageLoop to delete some object.
This must be a common pattern with an obvious solution (that I'm missing). Can anyone send pointers my way (heh)?
Thanks,
James