diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 19:50:36 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 19:50:36 +0000 |
commit | 2bda2f0dc0025aee1109545c6f0f06068dd8961d (patch) | |
tree | 3f9782378550e070bbe8665c65831768ac7a7579 /net/base | |
parent | 47dc04a3cb1f9ffefbee94a7d3547db6d1aefd8b (diff) | |
download | chromium_src-2bda2f0dc0025aee1109545c6f0f06068dd8961d.zip chromium_src-2bda2f0dc0025aee1109545c6f0f06068dd8961d.tar.gz chromium_src-2bda2f0dc0025aee1109545c6f0f06068dd8961d.tar.bz2 |
Add some instrumentation to SystemHostResolverProc() to capture the hostname when getaddrinfo() crashes.
This may help understand why we are seeing crashes in getaddrinfo() in the field.
BUG=22083
Review URL: http://codereview.chromium.org/378011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31267 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/host_resolver_proc.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc index cd6fc12..7e79198 100644 --- a/net/base/host_resolver_proc.cc +++ b/net/base/host_resolver_proc.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <algorithm> + #include "net/base/host_resolver_proc.h" #include "build/build_config.h" @@ -181,7 +183,24 @@ int SystemHostResolverProc(const std::string& host, // Restrict result set to only this socket type to avoid duplicates. hints.ai_socktype = SOCK_STREAM; - int err = getaddrinfo(host.c_str(), NULL, &hints, &ai); + // Copy up to the first 255 bytes of |host| onto the stack, so we can see + // what it was when getaddrinfo() crashes. + // TODO(eroman): Remove this once done investigating http://crbug.com/22083. + char buffer[256]; + size_t actual_size = host.size() + 1; // The size of |host| (including NULL). + size_t saved_size = std::min(actual_size, sizeof(buffer)); + memcpy(buffer, host.data(), saved_size - 1); + buffer[saved_size - 1] = '\0'; + + // Try to use the copy of |host| that was saved to the stack. + // (This will help rule out concurrent mutations on |host| as a factor.) + const char* host_cstr = (actual_size == saved_size) ? buffer : host.c_str(); + + int err = getaddrinfo(host_cstr, NULL, &hints, &ai); + + // Keep the variables alive so compiler can't optimize away. + CHECK(actual_size > 0 && buffer[saved_size - 1] == '\0'); + #if defined(OS_LINUX) net::DnsReloadTimer* dns_timer = Singleton<net::DnsReloadTimer>::get(); // If we fail, re-initialise the resolver just in case there have been any |