URLRequestContextGetters are often leaked |
||
Issue descriptionChrome Version: 58.0.3016.0 (Debug) What steps will reproduce the problem? (1) Run a Chrome Debug build, with logging enabled. What happens instead? Chrome will often report that a URLRequestContextGetter was leaked. To make it easier to identify why, we can add a StackTrace printout to the Debug logging in this case, to indicate where the leaked instance was created.
,
Feb 22 2017
Uploaded https://codereview.chromium.org/2702083002/, which adds a StackTrace member to the URLRequestContextGetter base, to Print() when we hit the leak condition in Debug builds.
,
Feb 22 2017
Does it actually matter that these leak on shutdown? Adding a StackTrace is only really valuable if we plan on "fixing" the clients. Which in itself is not worthwhile unless if we prohibit leaks in the future.
,
Feb 22 2017
FWIW, they seem to leak mid-session in some cases, not just during shutdown. Agreed, though, that there's no point fixing leaks if we don't add stronger checks to avoid regressions in future.
,
Feb 22 2017
Thanks wez. A mid-session leak is more of a problem, and may be worth looking at. That sounds symptomatic of clients spinning up a temporary thread for the networking and then stopping it (and in the process leaking the context getter because it was referenced after the thread stop)
,
Feb 22 2017
I can't seem to repro the mid-session leak right now, so I just grabbed the shutdown leak allocation stack: [25027:25027:0222/132733.482186:WARNING:url_request_context_getter.cc(44)] URLRequestContextGetter leaking due to no owning thread. Created at: #0 0x7f539b9e876b base::debug::StackTrace::StackTrace() #1 0x7f539b9e6dac base::debug::StackTrace::StackTrace() #2 0x7f539b39c37e net::URLRequestContextGetter::URLRequestContextGetter() #3 0x7f539e03503f ChromeURLRequestContextGetter::ChromeURLRequestContextGetter() #4 0x7f539e0357db ChromeURLRequestContextGetter::Create() #5 0x7f539e10c493 ProfileImplIOData::Handle::CreateMainRequestContextGetter() #6 0x7f539e107389 ProfileImpl::CreateRequestContext() #7 0x7f5395a01f42 content::StoragePartitionImplMap::Get() #8 0x7f5394e232ff content::(anonymous namespace)::GetStoragePartitionFromConfig() #9 0x7f5394e23280 content::BrowserContext::GetStoragePartition() #10 0x7f5394e23439 content::BrowserContext::GetDefaultStoragePartition() #11 0x7f539e1046d1 ProfileImpl::DoFinalInit() #12 0x7f539e10664f ProfileImpl::OnLocaleReady() #13 0x7f539e1038d9 ProfileImpl::OnPrefsLoaded() #14 0x7f539e1035bd ProfileImpl::ProfileImpl() #15 0x7f539e101c2a Profile::CreateProfile() #16 0x7f539dc36a87 ProfileManager::CreateProfileHelper() #17 0x7f539dc2ed7a ProfileManager::CreateAndInitializeProfile() #18 0x7f539dc2e967 ProfileManager::GetProfile() #19 0x7f53a02d4298 GetStartupProfile() #20 0x7f539e3bcaa2 (anonymous namespace)::CreatePrimaryProfile() #21 0x7f539e3bb13c ChromeBrowserMainParts::PreMainMessageLoopRunImpl() #22 0x7f539e3ba580 ChromeBrowserMainParts::PreMainMessageLoopRun() #23 0x7f5394e34af1 content::BrowserMainLoop::PreMainMessageLoopRun() #24 0x7f5394313485 _ZN4base8internal13FunctorTraitsIMN7content22IndexedDBCallbacksImpl13InternalStateEFvvEvE6InvokeIPS4_JEEEvS6_OT_DpOT0_ #25 0x7f5394e3fc31 _ZN4base8internal12InvokeHelperILb0EiE8MakeItSoIRKMN7content15BrowserMainLoopEFivEJPS5_EEEiOT_DpOT0_ #26 0x7f5394e3fbd7 _ZN4base8internal7InvokerINS0_9BindStateIMN7content15BrowserMainLoopEFivEJNS0_17UnretainedWrapperIS4_EEEEEFivEE7RunImplIRKS6_RKSt5tupleIJS8_EEJLm0EEEEiOT_OT0_NS_13IndexSequenceIJXspT1_EEEE #27 0x7f5394e3fb1c _ZN4base8internal7InvokerINS0_9BindStateIMN7content15BrowserMainLoopEFivEJNS0_17UnretainedWrapperIS4_EEEEEFivEE3RunEPNS0_13BindStateBaseE #28 0x7f53941f5aeb base::internal::RunMixin<>::Run() #29 0x7f53959ed06b content::StartupTaskRunner::RunAllTasksNow() #30 0x7f5394e326c0 content::BrowserMainLoop::CreateStartupTasks() #31 0x7f5394e43667 content::BrowserMainRunnerImpl::Initialize() #32 0x7f5394e2e97f content::BrowserMain() #33 0x7f5396648956 content::RunNamedProcessTypeMain() #34 0x7f539664abbc content::ContentMainRunnerImpl::Run() #35 0x7f5396647882 content::ContentMain() #36 0x7f539cb1b94a ChromeMain #37 0x7f539cb1b872 main #38 0x7f5387c43f45 __libc_start_main
,
Feb 22 2017
Right, the shutdown leak is 'expected' because we're no longer cleanly shutting down.
,
Feb 23 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/c59596d13ec0e105c72dd69661b8bcb505d9afa7 commit c59596d13ec0e105c72dd69661b8bcb505d9afa7 Author: wez <wez@chromium.org> Date: Thu Feb 23 00:04:56 2017 Print creator's call-stack on URLRequestContextGetter leak in Debug. This adds a StackTrace member to the URLRequestContextGetter base, to allow the call-stack that created the instance to be printed in case of it having to be leaked because of the owning thread having gone away. BUG= 693965 Review-Url: https://codereview.chromium.org/2702083002 Cr-Commit-Position: refs/heads/master@{#452289} [modify] https://crrev.com/c59596d13ec0e105c72dd69661b8bcb505d9afa7/net/url_request/url_request_context_getter.cc [modify] https://crrev.com/c59596d13ec0e105c72dd69661b8bcb505d9afa7/net/url_request/url_request_context_getter.h
,
Feb 23 2017
Re #7: I don't think we can depend on the necessary bits to detect and ignore when this happens during browser shutdown, so perhaps we should just revert it? That said, I thought we still [try to] shutdown the browser cleanly; it's just renderers that we exit without teardown?
,
Feb 23 2017
Nope, like I mentioned on our hangout when discussing this earlier, but perhaps not clearly, the policy applies to shutdown in general. That is, the consequence of that discussion has been to affect _browser_ shutdown and not just _renderer_ shutdown (in my experience of the CLs I've seen)
,
Feb 23 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/55fa5c6ec96a1f955cf0c3a85b6689239e8ab08e commit 55fa5c6ec96a1f955cf0c3a85b6689239e8ab08e Author: wez <wez@chromium.org> Date: Thu Feb 23 20:24:26 2017 Revert of Print creator's call-stack on URLRequestContextGetter leak in Debug. (patchset #1 id:1 of https://codereview.chromium.org/2702083002/ ) Reason for revert: This output is too noisy on browser shutdown, where is apparently now expected that we leak things. Original issue's description: > Print creator's call-stack on URLRequestContextGetter leak in Debug. > > This adds a StackTrace member to the URLRequestContextGetter base, to > allow the call-stack that created the instance to be printed in case > of it having to be leaked because of the owning thread having gone away. > > BUG= 693965 > > Review-Url: https://codereview.chromium.org/2702083002 > Cr-Commit-Position: refs/heads/master@{#452289} > Committed: https://chromium.googlesource.com/chromium/src/+/c59596d13ec0e105c72dd69661b8bcb505d9afa7 TBR=rsleevi@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= 693965 Review-Url: https://codereview.chromium.org/2708923008 Cr-Commit-Position: refs/heads/master@{#452605} [modify] https://crrev.com/55fa5c6ec96a1f955cf0c3a85b6689239e8ab08e/net/url_request/url_request_context_getter.cc [modify] https://crrev.com/55fa5c6ec96a1f955cf0c3a85b6689239e8ab08e/net/url_request/url_request_context_getter.h
,
Feb 24 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by rsleevi@chromium.org
, Feb 21 2017