Commit ac0c504b authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

Add URLRequest creation stack traces to AssertNoURLRequests crashes.

We have a top crasher here (Again...), and need to figure out just
what's going on. Hopefully once we ship the network service, we'll
never see these crashes again (Well, at least in the network
process).

Bug: 800391
Change-Id: Ifbd45274ac73ca90c7103aea66ba0f7d254c9e6e
Reviewed-on: https://chromium-review.googlesource.com/916894Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536575}
parent 2319141f
......@@ -12,6 +12,7 @@
#include <vector>
#include "base/debug/leak_tracker.h"
#include "base/debug/stack_trace.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/optional.h"
......@@ -693,6 +694,12 @@ class NET_EXPORT URLRequest : public base::SupportsUserData {
// called with a response from the server.
void SetResponseHeadersCallback(ResponseHeadersCallback callback);
// Stack trace when the URLRequest was created.
// TODO(mmenke): Remove once https://crbug.com/800391 is resolved.
const base::debug::StackTrace& creation_stack_trace() const {
return creation_stack_trace_;
}
protected:
// Allow the URLRequestJob class to control the is_pending() flag.
void set_is_pending(bool value) { is_pending_ = value; }
......@@ -908,6 +915,11 @@ class NET_EXPORT URLRequest : public base::SupportsUserData {
RequestHeadersCallback request_headers_callback_;
ResponseHeadersCallback response_headers_callback_;
// Automatically initialized in constructor to be the stack trace when |this|
// is created.
// TODO(mmenke): Remove once https://crbug.com/800391 is resolved.
const base::debug::StackTrace creation_stack_trace_;
THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(URLRequest);
......
......@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "base/debug/alias.h"
#include "base/debug/stack_trace.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
......@@ -142,9 +143,12 @@ void URLRequestContext::AssertNoURLRequests() const {
// many we leaked so we have an idea of how bad it is.
const URLRequest* request = *url_requests_->begin();
int load_flags = request->load_flags();
base::debug::StackTrace creation_stack_trace =
request->creation_stack_trace();
DEBUG_ALIAS_FOR_GURL(url_buf, request->url());
base::debug::Alias(&num_requests);
base::debug::Alias(&load_flags);
base::debug::Alias(&creation_stack_trace);
CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: "
<< request->url().spec().c_str() << ".";
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment