summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 05:08:35 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 05:08:35 +0000
commitb8d6e06f4e2f41cb5148582eab2b91a32a7fc83a (patch)
tree95945a8ad06966370b6d26682655ff815849ccf0 /net
parent0f5aa0ccd90ffe0ed7910be4afd86f15f71e5fdf (diff)
downloadchromium_src-b8d6e06f4e2f41cb5148582eab2b91a32a7fc83a.zip
chromium_src-b8d6e06f4e2f41cb5148582eab2b91a32a7fc83a.tar.gz
chromium_src-b8d6e06f4e2f41cb5148582eab2b91a32a7fc83a.tar.bz2
Add some instrumentation to track down a crash.
See if the state machine in SSLClientSocketNSS is failing to cancel the origin bound certificate request. BUG=113233 Review URL: http://codereview.chromium.org/9383034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121851 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/origin_bound_cert_service.cc59
-rw-r--r--net/base/origin_bound_cert_service.h12
-rw-r--r--net/socket/ssl_client_socket_nss.cc11
-rw-r--r--net/socket/ssl_client_socket_nss.h1
4 files changed, 83 insertions, 0 deletions
diff --git a/net/base/origin_bound_cert_service.cc b/net/base/origin_bound_cert_service.cc
index 1edf9c0..3668143 100644
--- a/net/base/origin_bound_cert_service.cc
+++ b/net/base/origin_bound_cert_service.cc
@@ -86,7 +86,30 @@ class OriginBoundCertServiceRequest {
bool canceled() const { return callback_.is_null(); }
+ void DebugGetId(DebugOBCertRequestId* id) {
+ *id = id_;
+ }
+
+ void DebugSetId(const std::string& origin,
+ OriginBoundCertServiceJob* job) {
+ id_.origin = origin;
+ id_.job = job;
+ id_.request = this;
+
+
+ // Also give ourselves a unique ID, since pointer values are not unique and
+ // may be re-used (so we need this ID to be sure it really is the same
+ // thing).
+ static int count = 0;
+ id_.id = count++;
+ }
+
+ bool DebugMatchesId(const DebugOBCertRequestId& id) {
+ return id_.id == id.id;
+ }
+
private:
+ DebugOBCertRequestId id_;
CompletionCallback callback_;
SSLClientCertType* type_;
std::string* private_key_;
@@ -250,6 +273,15 @@ class OriginBoundCertServiceJob {
PostAll(error, type, private_key, cert);
}
+ OriginBoundCertServiceRequest* DebugGetRequest(
+ const DebugOBCertRequestId& id) {
+ std::vector<OriginBoundCertServiceRequest*>::const_iterator it =
+ std::find(requests_.begin(), requests_.end(), id.request);
+ if (it != requests_.end())
+ return *it;
+ return NULL;
+ }
+
private:
void PostAll(int error,
SSLClientCertType type,
@@ -393,6 +425,8 @@ int OriginBoundCertService::GetOriginBoundCert(
new OriginBoundCertServiceRequest(callback, type, private_key, cert);
job->AddRequest(request);
*out_req = request;
+
+ request->DebugSetId(origin, job);
return ERR_IO_PENDING;
}
@@ -400,6 +434,31 @@ OriginBoundCertStore* OriginBoundCertService::GetCertStore() {
return origin_bound_cert_store_.get();
}
+void OriginBoundCertService::DebugGetRequestId(
+ RequestHandle req, DebugOBCertRequestId* id) {
+ OriginBoundCertServiceRequest* request =
+ reinterpret_cast<OriginBoundCertServiceRequest*>(req);
+ request->DebugGetId(id);
+}
+
+bool OriginBoundCertService::DebugIsRequestAlive(
+ const DebugOBCertRequestId& id) {
+ std::map<std::string, OriginBoundCertServiceJob*>::const_iterator it =
+ inflight_.find(id.origin);
+
+ if (it == inflight_.end())
+ return false;
+
+ if (it->second != id.job)
+ return false;
+
+ OriginBoundCertServiceRequest* req = id.job->DebugGetRequest(id);
+ if (!req)
+ return false;
+
+ return req->DebugMatchesId(id);
+}
+
// static
int OriginBoundCertService::GenerateCert(const std::string& origin,
SSLClientCertType type,
diff --git a/net/base/origin_bound_cert_service.h b/net/base/origin_bound_cert_service.h
index 298c3e9..06b64e9 100644
--- a/net/base/origin_bound_cert_service.h
+++ b/net/base/origin_bound_cert_service.h
@@ -24,6 +24,13 @@ class OriginBoundCertServiceJob;
class OriginBoundCertServiceWorker;
class OriginBoundCertStore;
+struct NET_EXPORT DebugOBCertRequestId {
+ std::string origin;
+ OriginBoundCertServiceJob* job;
+ void* request;
+ int id;
+};
+
// A class for creating and fetching origin bound certs.
// Inherits from NonThreadSafe in order to use the function
// |CalledOnValidThread|.
@@ -85,6 +92,11 @@ class NET_EXPORT OriginBoundCertService
uint64 cert_store_hits() const { return cert_store_hits_; }
uint64 inflight_joins() const { return inflight_joins_; }
+ // TODO(eroman): Delete this when done.
+ // Temporary instrumentation for debugging issue 113233.
+ void DebugGetRequestId(RequestHandle req, DebugOBCertRequestId* id);
+ bool DebugIsRequestAlive(const DebugOBCertRequestId& id);
+
private:
friend class OriginBoundCertServiceWorker; // Calls HandleResult.
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index ba07fa4..b47978d 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -1610,6 +1610,11 @@ int SSLClientSocketNSS::DoGetOBCertComplete(int result) {
net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_GET_ORIGIN_BOUND_CERT,
result);
client_auth_cert_needed_ = false;
+
+ if (ob_cert_request_handle_) {
+ CHECK(!origin_bound_cert_service_->DebugIsRequestAlive(
+ ob_cert_request_id_));
+ }
ob_cert_request_handle_ = NULL;
if (result != OK)
@@ -2207,6 +2212,8 @@ SECStatus SSLClientSocketNSS::OriginBoundClientAuthHandler(
std::vector<uint8> requested_cert_types(cert_types->data,
cert_types->data + cert_types->len);
net_log_.BeginEvent(NetLog::TYPE_SSL_GET_ORIGIN_BOUND_CERT, NULL);
+
+ CHECK(!ob_cert_request_handle_);
int error = origin_bound_cert_service_->GetOriginBoundCert(
origin,
requested_cert_types,
@@ -2218,6 +2225,10 @@ SECStatus SSLClientSocketNSS::OriginBoundClientAuthHandler(
&ob_cert_request_handle_);
if (error == ERR_IO_PENDING) {
+ CHECK(ob_cert_request_handle_);
+ origin_bound_cert_service_->DebugGetRequestId(
+ ob_cert_request_handle_, &ob_cert_request_id_);
+
// Asynchronous case.
client_auth_cert_needed_ = true;
return SECWouldBlock;
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index e9f4f48..ccf762b 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -261,6 +261,7 @@ class SSLClientSocketNSS : public SSLClientSocket {
std::string ob_private_key_;
std::string ob_cert_;
OriginBoundCertService::RequestHandle ob_cert_request_handle_;
+ DebugOBCertRequestId ob_cert_request_id_;
// True if NSS has called HandshakeCallback.
bool handshake_callback_called_;