From 7f5a75a5ee81ddb09effe754e2c12e84d768b85d Mon Sep 17 00:00:00 2001 From: "pamg@google.com" Date: Tue, 16 Dec 2008 01:19:38 +0000 Subject: Add a call to MemoryDebug::MarkAsInitialized to the new network code to avoid false UMR reports from Purify due to asynchronous filling of memory from the socket. BUG=5297 TEST=run test_shell.exe http://localhost:8080/multipart/invalid-image-data-standalone.html in Purify, see no UMRs in net code. Or watch the layout-test Purify buildbot running http/tests/invalid-image-data{-standalone}.html Review URL: http://codereview.chromium.org/13331 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7028 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/tcp_client_socket_win.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'net') diff --git a/net/base/tcp_client_socket_win.cc b/net/base/tcp_client_socket_win.cc index 11a6de3..1111d71 100644 --- a/net/base/tcp_client_socket_win.cc +++ b/net/base/tcp_client_socket_win.cc @@ -4,6 +4,7 @@ #include "net/base/tcp_client_socket.h" +#include "base/memory_debug.h" #include "base/string_util.h" #include "base/trace_event.h" #include "net/base/net_errors.h" @@ -175,6 +176,14 @@ int TCPClientSocket::Read(char* buf, BOOL ok = WSAResetEvent(overlapped_.hEvent); CHECK(ok); TRACE_EVENT_END("socket.read", this, StringPrintf("%d bytes", num)); + + // Because of how WSARecv fills memory when used asynchronously, Purify + // isn't able to detect that it's been initialized, so it scans for 0xcd + // in the buffer and reports UMRs (uninitialized memory reads) for those + // individual bytes. We override that in PURIFY builds to avoid the false + // error reports. + // See bug 5297. + base::MemoryDebug::MarkAsInitialized(buffer_.buf, num); return static_cast(num); } int err = WSAGetLastError(); -- cgit v1.1