New issue
Advanced search Search tips

Issue 595156 link

Starred by 2 users

Issue metadata

Status: Duplicate
Merged: issue 595792
Owner: ----
Closed: Mar 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

net::ClientSocketPoolManager leaking socket handles.

Project Member Reported by reillyg@chromium.org, Mar 15 2016

Issue description

Dr. Memory reports that there are socket handles leaking out of net::ClientSocketPoolManager:

https://build.chromium.org/p/chromium.memory.fyi/builders/Windows%20Content%20Browser%20%28DrMemory%20full%29%20%285%29/builds/7766

HANDLE LEAK: KERNEL handle 0x0000089c and 2 similar handle(s) were opened but not closed:
# 0 system call NtCreateFile
# 1 MSWSOCK.dll!?                                                             +0x0      (0x734a3529 <MSWSOCK.dll+0x3529>)
# 2 MSWSOCK.dll!?                                                             +0x0      (0x734a3799 <MSWSOCK.dll+0x3799>)
# 3 WS2_32.dll!WSASocketW                                                     +0x9c     (0x75e03d70 <WS2_32.dll+0x3d70>)
# 4 net.dll!net::CreatePlatformSocket                                          [net\socket\socket_descriptor.cc:23]
# 5 net.dll!net::TCPSocketWin::Open                                            [net\socket\tcp_socket_win.cc:271]
# 6 net.dll!net::TCPClientSocket::OpenSocket                                   [net\socket\tcp_client_socket.cc:370]
# 7 net.dll!net::TCPClientSocket::DoConnect                                    [net\socket\tcp_client_socket.cc:141]
# 8 net.dll!net::TCPClientSocket::DoConnectLoop                                [net\socket\tcp_client_socket.cc:104]
# 9 net.dll!net::TCPClientSocket::Connect                                      [net\socket\tcp_client_socket.cc:84]
#10 net.dll!net::TransportConnectJob::DoTransportConnect                       [net\socket\transport_client_socket_pool.cc:317]
#11 net.dll!net::TransportConnectJobHelper::DoLoop<>                           [net\socket\transport_client_socket_pool.h:355]
#12 net.dll!net::TransportConnectJobHelper::DoConnectInternal<>                [net\socket\transport_client_socket_pool.h:318]
#13 net.dll!net::TransportConnectJob::ConnectInternal                          [net\socket\transport_client_socket_pool.cc:473]
#14 net.dll!net::internal::ClientSocketPoolBaseHelper::RequestSocketInternal   [net\socket\client_socket_pool_base.cc:420]
#15 net.dll!net::internal::ClientSocketPoolBaseHelper::RequestSocket           [net\socket\client_socket_pool_base.cc:291]
#16 net.dll!net::TransportClientSocketPool::RequestSocket                      [net\socket\transport_client_socket_pool.cc:533]
#17 net.dll!net::ClientSocketHandle::Init<>                                    [net\socket\client_socket_handle.h:254]
#18 net.dll!net::`anonymous namespace'::InitSocketPoolHelper                   [net\socket\client_socket_pool_manager.cc:302]
#19 net.dll!net::InitSocketHandleForHttpRequest                                [net\socket\client_socket_pool_manager.cc:390]
#20 net.dll!net::HttpStreamFactoryImpl::Job::DoInitConnection                  [net\http\http_stream_factory_impl_job.cc:1123]
#21 net.dll!net::HttpStreamFactoryImpl::Job::DoLoop                            [net\http\http_stream_factory_impl_job.cc:774]
#22 net.dll!net::HttpStreamFactoryImpl::Job::RunLoop                           [net\http\http_stream_factory_impl_job.cc:622]
#23 net.dll!net::HttpStreamFactoryImpl::Job::StartInternal                     [net\http\http_stream_factory_impl_job.cc:808]
#24 net.dll!net::HttpStreamFactoryImpl::Job::Start                             [net\http\http_stream_factory_impl_job.cc:253]
#25 net.dll!net::HttpStreamFactoryImpl::RequestStreamInternal                  [net\http\http_stream_factory_impl.cc:141]
#26 net.dll!net::HttpStreamFactoryImpl::RequestStream                          [net\http\http_stream_factory_impl.cc:57]
#27 net.dll!net::HttpNetworkTransaction::DoCreateStream                        [net\http\http_network_transaction.cc:851]
#28 net.dll!net::HttpNetworkTransaction::DoLoop                                [net\http\http_network_transaction.cc:722]
#29 net.dll!net::HttpNetworkTransaction::Start                                 [net\http\http_network_transaction.cc:213]
#30 net.dll!net::HttpCache::Transaction::DoSendRequest                         [net\http\http_cache_transaction.cc:1318]
#31 net.dll!net::HttpCache::Transaction::DoLoop                                [net\http\http_cache_transaction.cc:768]
#32 net.dll!base::internal::Invoker<>::Run                                     [base\bind_internal.h:352]
#33 net.dll!net::HttpCache::OnIOComplete                                       [net\http\http_cache.cc:1063]
#34 net.dll!net::HttpCache::OnPendingOpComplete                                [net\http\http_cache.cc:1113]
#35 net.dll!base::internal::Invoker<>::Run                                     [base\bind_internal.h:352]
#36 net.dll!disk_cache::InFlightBackendIO::OnOperationComplete                 [net\disk_cache\blockfile\in_flight_backend_io.cc:531]
#37 net.dll!disk_cache::InFlightIO::InvokeCallback                             [net\disk_cache\blockfile\in_flight_io.cc:108]
#38 net.dll!disk_cache::BackgroundIO::OnIOSignalled                            [net\disk_cache\blockfile\in_flight_io.cc:28]
#39 net.dll!base::internal::Invoker<>::Run                                     [base\bind_internal.h:352]
Note: @0:02:53.862 in thread 3172
Note: handles created with the same callstack are closed here:
Note: # 0 system call NtClose
Note: # 1 MSWSOCK.dll!?                                                   +0x0      (0x734a2b8f <MSWSOCK.dll+0x2b8f>)
Note: # 2 MSWSOCK.dll!?                                                   +0x0      (0x734a2c50 <MSWSOCK.dll+0x2c50>)
Note: # 3 WS2_32.dll!closesocket                                          +0x49     (0x75e03962 <WS2_32.dll+0x3962>)
Note: # 4 net.dll!net::TCPSocketWin::Close                                 [net\socket\tcp_socket_win.cc:619]
Note: # 5 net.dll!net::TCPClientSocket::Disconnect                         [net\socket\tcp_client_socket.cc:186]
Note: # 6 net.dll!net::HttpNetworkTransaction::DoReadBodyComplete          [net\http\http_network_transaction.cc:1285]
Note: # 7 net.dll!net::HttpNetworkTransaction::DoLoop                      [net\http\http_network_transaction.cc:795]
Note: # 8 net.dll!net::HttpNetworkTransaction::Read                        [net\http\http_network_transaction.cc:391]
Note: # 9 net.dll!net::HttpCache::Transaction::DoNetworkRead               [net\http\http_cache_transaction.cc:1676]
Note: #10 net.dll!net::HttpCache::Transaction::Read                        [net\http\http_cache_transaction.cc:384]
Note: #11 net.dll!net::URLRequestHttpJob::ReadRawData                      [net\url_request\url_request_http_job.cc:1373]
Note: #12 net.dll!net::URLRequestJob::ReadRawDataHelper                    [net\url_request\url_request_job.cc:836]
Note: #13 net.dll!net::URLRequestJob::Read                                 [net\url_request\url_request_job.cc:126]
Note: #14 net.dll!net::URLRequest::Read                                    [net\url_request\url_request.cc:766]
Note: #15 content.dll!content::ResourceLoader::ReadMore                    [content\browser\loader\resource_loader.cc:615]
Note: #16 content.dll!content::ResourceLoader::StartReading                [content\browser\loader\resource_loader.cc:560]
Note: #17 content.dll!content::ResourceLoader::OnReadCompleted             [content\browser\loader\resource_loader.cc:383]
Note: #18 net.dll!net::URLRequest::NotifyReadCompleted                     [net\url_request\url_request.cc:1156]
Note: #19 net.dll!net::URLRequestJob::ReadRawDataComplete                  [net\url_request\url_request_job.cc:549]
Note: #20 net.dll!net::URLRequestHttpJob::OnReadCompleted                  [net\url_request\url_request_http_job.cc:1048]
Note: #21 net.dll!base::internal::Invoker<>::Run                           [base\bind_internal.h:352]
Note: #22 net.dll!net::HttpCache::Transaction::DoLoop                      [net\http\http_cache_transaction.cc:863]
Note: #23 net.dll!base::internal::Invoker<>::Run                           [base\bind_internal.h:352]
Note: #24 net.dll!disk_cache::InFlightBackendIO::OnOperationComplete       [net\disk_cache\blockfile\in_flight_backend_io.cc:531]
Note: #25 net.dll!disk_cache::InFlightIO::InvokeCallback                   [net\disk_cache\blockfile\in_flight_io.cc:108]
Note: #26 net.dll!disk_cache::BackgroundIO::OnIOSignalled                  [net\disk_cache\blockfile\in_flight_io.cc:28]
Note: #27 net.dll!base::internal::Invoker<>::Run                           [base\bind_internal.h:352]
Note: #28 base.dll!base::debug::TaskAnnotator::RunTask                     [base\debug\task_annotator.cc:51]
Note: #29 base.dll!base::MessageLoop::RunTask                              [base\message_loop\message_loop.cc:476]
Note: #30 base.dll!base::MessageLoop::DeferOrRunPendingTask                [base\message_loop\message_loop.cc:485]
Note: #31 base.dll!base::MessageLoop::DoWork                               [base\message_loop\message_loop.cc:597]
Note: #32 base.dll!base::MessagePumpForIO::DoRunLoop                       [base\message_loop\message_pump_win.cc:485]
Note: #33 base.dll!base::MessageLoop::RunHandler                           [base\message_loop\message_loop.cc:440]
Note: #34 base.dll!base::MessageLoop::Run                                  [base\message_loop\message_loop.cc:293]
Note: #35 base.dll!base::Thread::Run                                       [base\threading\thread.cc:202]
Note: #36 content.dll!content::BrowserThreadImpl::IOThreadRun              [content\browser\browser_thread_impl.cc:215]
Note: #37 content.dll!content::BrowserThreadImpl::Run                      [content\browser\browser_thread_impl.cc:251]
Note: #38 base.dll!base::Thread::ThreadMain                                [base\threading\thread.cc:254]
Note: #39 base.dll!base::`anonymous namespace'::ThreadFunc                 [base\threading\platform_thread_win.cc:84]
The report came from the `EncryptedMediaTest.UnknownKeySystemThrowsException` test.
 

Comment 1 by mmenke@chromium.org, Mar 15 2016

Components: -Internals>Network>HTTP Internals>Network
Something's not shutting down its requests before profile teardown, I suspect.  Not an HTTP issue.
Project Member

Comment 2 by bugdroid1@chromium.org, Mar 15 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/26ddffa8e68c6868c28b36b3061ba224585b3e84

commit 26ddffa8e68c6868c28b36b3061ba224585b3e84
Author: reillyg <reillyg@chromium.org>
Date: Tue Mar 15 23:58:37 2016

Add remaining suppressions for current Windows issues.

This should cover the rest of the suppressions needed to clean up the
Dr. Memory bots.

BUG= 595146 ,595149, 595156 , 595158 
TBR=thestig@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/1807513003

Cr-Commit-Position: refs/heads/master@{#381355}

[modify] https://crrev.com/26ddffa8e68c6868c28b36b3061ba224585b3e84/tools/valgrind/drmemory/suppressions_full.txt

Components: -Internals>Network
Labels: Needs-Feedback
Agree with Matt that this isn't really a //net thing - so I'm going to remove the Internals>Network label, because the root leak is likely caused by someone holding the //net stack wrong, rather than the //net stack itself.

reillyg: Is there any way to add additional allocations, such as to the URLRequestJob's instruction pointer at time of allocation or to the URL being requested? That would likely identify who the culprit is that isn't shutting down the //net stack.
Components: Internals>Media>Encrypted
Labels: -Needs-Feedback
Not that I know of but I'm still learning how to drive Dr. Memory. I think you'd have to add instrumentation to //net to detect URLRequestJobs that are still in flight at shutdown.

Assigning to the EME component for further triage.

Comment 5 by mmenke@chromium.org, Mar 16 2016

Net already should do this.  Unfortunately, top level network stack objects can share underlying lower level components, so if the main network stack is torn down, then the request is torn down, then the URLRequestContext that was parasitically leeching off the main network stack shuts down, we may see something like this, though I think we'd see a UAF or somesuch as well.
I doubt that the EME tests are the issue. EncryptedMediaTest.UnknownKeySystemThrowsException basically starts the EmbeddedTestServer, loads media/test/data/eme_player.html (which in turns loads all 11 JavaScript files in media/test/data/eme_player_js/), and then tries to play media/test/data/bear-a_enc-a.webm. It does nothing special as far as accessing files.

When I looked through the logs that ran the test (https://build.chromium.org/p/chromium.memory.fyi/builders/Windows%20Content%20Browser%20%28DrMemory%20full%29%20%285%29/builds/7766/steps/memory%20test%3A%20content_browsertests_4/logs/stdio), I see an error occurring:

[4956:4048:0315/070323:15957669:ERROR:shell.cc(293)] Error: Instance: exe:chrome attempting to register an instance for a process it created for target: exe:chrome_renderer without the mojo:shell{client_process} capability class.
Backtrace:
	net::ShouldSniffMimeType [0x6B513570+160] (c:\b\build\slave\drm-cr\build\src\net\base\mime_sniffer.cc:831)
	content::MimeTypeResourceHandler::ShouldSniffContent [0x68DA4B56+198] (c:\b\build\slave\drm-cr\build\src\content\browser\loader\mime_type_resource_handler.cc:236)
	content::MimeTypeResourceHandler::OnResponseStarted [0x68DA3F08+72] (c:\b\build\slave\drm-cr\build\src\content\browser\loader\mime_type_resource_handler.cc:96)
	content::ThrottlingResourceHandler::OnResponseStarted [0x68DC5B04+100] (c:\b\build\slave\drm-cr\build\src\content\browser\loader\throttling_resource_handler.cc:130)
	content::ResourceLoader::CompleteResponseStarted [0x68DBC720+208] (c:\b\build\slave\drm-cr\build\src\content\browser\loader\resource_loader.cc:550)
	content::ResourceLoader::OnResponseStarted [0x68DBCFB5+37] (c:\b\build\slave\drm-cr\build\src\content\browser\loader\resource_loader.cc:350)
	net::URLRequest::NotifyResponseStarted [0x6B72ED5A+154] (c:\b\build\slave\drm-cr\build\src\net\url_request\url_request.cc:840)
	net::URLRequestJob::NotifyHeadersComplete [0x6B742319+745] (c:\b\build\slave\drm-cr\build\src\net\url_request\url_request_job.cc:464)
	net::URLRequestHttpJob::NotifyHeadersComplete [0x6B73DF79+953] (c:\b\build\slave\drm-cr\build\src\net\url_request\url_request_http_job.cc:482)
	net::URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete [0x6B73F98D+445] (c:\b\build\slave\drm-cr\build\src\net\url_request\url_request_http_job.cc:812)
	net::URLRequestHttpJob::OnStartCompleted [0x6B73E396+662] (c:\b\build\slave\drm-cr\build\src\net\url_request\url_request_http_job.cc:998)
	base::internal::Invoker<base::IndexSequence<0>,base::internal::BindState<base::internal::RunnableAdapter<void (__thiscall net::URLRequestHttpJob::*)(int)>,void __cdecl(net::URLRequestHttpJob *,int),base::internal::UnretainedWrapper<net::URLRequestHttpJob> [0x6B73F78E+30] (c:\b\build\slave\drm-cr\build\src\base\bind_internal.h:352)
	net::HttpCache::Transaction::DoLoop [0x6B60A550+688] (c:\b\build\slave\drm-cr\build\src\net\http\http_cache_transaction.cc:863)
	base::internal::Invoker<base::IndexSequence<0>,base::internal::BindState<base::internal::RunnableAdapter<void (__thiscall net::HttpCache::Transaction::*)(int)>,void __cdecl(net::HttpCache::Transaction *,int),base::WeakPtr<net::HttpCache::Transaction> >,ba [0x6B60D765+85] (c:\b\build\slave\drm-cr\build\src\base\bind_internal.h:352)
	disk_cache::InFlightBackendIO::OnOperationComplete [0x6B58AB98+120] (c:\b\build\slave\drm-cr\build\src\net\disk_cache\blockfile\in_flight_backend_io.cc:531)
	disk_cache::InFlightIO::InvokeCallback [0x6B58BDB7+119] (c:\b\build\slave\drm-cr\build\src\net\disk_cache\blockfile\in_flight_io.cc:108)
	disk_cache::BackgroundIO::OnIOSignalled [0x6B58BECE+62] (c:\b\build\slave\drm-cr\build\src\net\disk_cache\blockfile\in_flight_io.cc:28)
	base::internal::Invoker<base::IndexSequence<0>,base::internal::BindState<base::internal::RunnableAdapter<void (__thiscall disk_cache::BackgroundIO::*)(void)>,void __cdecl(disk_cache::BackgroundIO *),disk_cache::BackgroundIO * &>,base::internal::InvokeHelp [0x6B58BFAF+31] (c:\b\build\slave\drm-cr\build\src\base\bind_internal.h:352)
	base::debug::TaskAnnotator::RunTask [0x6D51FA13+243] (c:\b\build\slave\drm-cr\build\src\base\debug\task_annotator.cc:51)
	base::MessageLoop::RunTask [0x6D547203+419] (c:\b\build\slave\drm-cr\build\src\base\message_loop\message_loop.cc:477)
	base::MessageLoop::DeferOrRunPendingTask [0x6D5462ED+45] (c:\b\build\slave\drm-cr\build\src\base\message_loop\message_loop.cc:488)
	base::MessageLoop::DoWork [0x6D5467ED+157] (c:\b\build\slave\drm-cr\build\src\base\message_loop\message_loop.cc:597)
	base::MessagePumpForIO::DoRunLoop [0x6D548BFA+122] (c:\b\build\slave\drm-cr\build\src\base\message_loop\message_pump_win.cc:485)
	base::MessagePumpWin::Run [0x6D5495C6+54] (c:\b\build\slave\drm-cr\build\src\base\message_loop\message_pump_win.cc:52)
	base::MessageLoop::RunHandler [0x6D547051+17] (c:\b\build\slave\drm-cr\build\src\base\message_loop\message_loop.cc:440)
	base::RunLoop::Run [0x6D56A1F9+41] (c:\b\build\slave\drm-cr\build\src\base\run_loop.cc:36)
	base::MessageLoop::Run [0x6D54701D+29] (c:\b\build\slave\drm-cr\build\src\base\message_loop\message_loop.cc:294)
	base::Thread::Run [0x6D58FF4B+11] (c:\b\build\slave\drm-cr\build\src\base\threading\thread.cc:203)
	content::BrowserThreadImpl::IOThreadRun [0x68BC38F0+32] (c:\b\build\slave\drm-cr\build\src\content\browser\browser_thread_impl.cc:216)
	content::BrowserThreadImpl::Run [0x68BC431A+362] (c:\b\build\slave\drm-cr\build\src\content\browser\browser_thread_impl.cc:251)
	base::Thread::ThreadMain [0x6D5903AB+347] (c:\b\build\slave\drm-cr\build\src\base\threading\thread.cc:257)
	base::`anonymous namespace'::ThreadFunc [0x6D588690+128] (c:\b\build\slave\drm-cr\build\src\base\threading\platform_thread_win.cc:86)
	BaseThreadInitThunk [0x7675337A+18]
	RtlInitializeExceptionChain [0x775092B2+99]
	RtlInitializeExceptionChain [0x77509285+54]

Eventually followed by (after the leak report):
~~Dr.M~~ WARNING: application exited with abnormal code 0xc0000005

No idea why the error is generated, but looks like it happens numerous times in the log file, including for other tests. My suspicion is that this crash is causing the resources to leak (missing cleanup?).

The other EME test in the log (MSE_ClearKey/EncryptedMediaTest.ConfigChangeVideo) does basically the same thing, except it uses media/test/data/mse_config_change.html as the starting page. Same crash reported, but no leak detected.
Status: Available (was: Untriaged)
encryted issue as per #6. can anybody pick it up?
Cc: jrumm...@chromium.org xhw...@chromium.org ddorwin@chromium.org

Comment 9 by xhw...@chromium.org, Mar 17 2016

Components: -Internals>Media>Encrypted
Sorry, per #6, this seems NOT an issue with encrypted test, which I agree.

Removing Internals>Media>Encrypted component.
Yeah this could be due to DrMemory issue ( crbug.com/594808 ) We're temporarily switching back to VS2013 and I'll see if that fixes this.
The crash is now fixed ( issue 595792 ).  Handle leaks, unlike heap leaks, are in fact subject to reporting changes on crashes, so this will likely go away with the fix now in.
Mergedinto: 595792
Status: Duplicate (was: Available)
Project Member

Comment 13 by bugdroid1@chromium.org, Mar 20 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/81b119c2386ef476253fca400e865c4813aa0139

commit 81b119c2386ef476253fca400e865c4813aa0139
Author: bruening <bruening@chromium.org>
Date: Sun Mar 20 20:25:44 2016

Remove Dr. Memory suppression that is no longer needed.

We strongly suspect that this handle leak is caused by the  issue 595792 
crash and that the suppression is not needed.

BUG= 595156 , 595792 
TBR=oshima
NOTRY=true

Review URL: https://codereview.chromium.org/1821503002

Cr-Commit-Position: refs/heads/master@{#382230}

[modify] https://crrev.com/81b119c2386ef476253fca400e865c4813aa0139/tools/valgrind/drmemory/suppressions_full.txt

Sign in to add a comment