trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sor...@apache.org
Subject [1/2] git commit: TS-2019 Fix the "vector inconsistency" errors.
Date Mon, 03 Mar 2014 22:31:29 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/4.2.x 90a660508 -> bc6625fa0


TS-2019 Fix the "vector inconsistency" errors.

(cherry picked from commit af3e7aa871740e85b0e610b3fd4c2dd741bfe52a)

Conflicts:
	CHANGES


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/aa191f82
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/aa191f82
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/aa191f82

Branch: refs/heads/4.2.x
Commit: aa191f8214c4318516914082f4e72bf671f06c35
Parents: 90a6605
Author: Alan M. Carroll <amc@network-geographics.com>
Authored: Mon Mar 3 07:27:32 2014 -0600
Committer: Phil Sorber <sorber@apache.org>
Committed: Mon Mar 3 15:30:09 2014 -0700

----------------------------------------------------------------------
 CHANGES                   |  2 ++
 iocore/cache/CacheRead.cc | 25 +++++++++++++++++++--
 proxy/hdrs/HTTP.cc        | 51 +++++++++++++++++++++++++-----------------
 3 files changed, 55 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/aa191f82/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index d9d809d..a9c0ed2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-2019] Fix the "vector inconsistency" errors.
+
   *) [TS-2593] HTTPS to origin fails on CentOS6.x. This is a regression of
    sort from TS-2355.
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/aa191f82/iocore/cache/CacheRead.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc
index 5e8c6ac..e1e5542 100644
--- a/iocore/cache/CacheRead.cc
+++ b/iocore/cache/CacheRead.cc
@@ -1061,12 +1061,33 @@ CacheVC::openReadStartHead(int event, Event * e)
 #ifdef HTTP_CACHE
     CacheHTTPInfo *alternate_tmp;
     if (frag_type == CACHE_FRAG_TYPE_HTTP) {
+      uint32_t uml;
       ink_assert(doc->hlen);
       if (!doc->hlen)
         goto Ldone;
-      if (vector.get_handles(doc->hdr(), doc->hlen) != doc->hlen) {
+      if ((uml = vector.get_handles(doc->hdr(), doc->hlen)) != doc->hlen) {
         if (buf) {
-          Note("OpenReadHead failed for cachekey %X : vector inconsistency with %d", key.word(0),
doc->hlen);
+          HTTPCacheAlt* alt = reinterpret_cast<HTTPCacheAlt*>(doc->hdr());
+          int32_t alt_length = 0;
+          // count should be reasonable, as vector is initialized and unlikly to be too corrupted
+          // by bad disk data - count should be the number of successfully unmarshalled alts.
+          for ( int32_t i = 0 ; i < vector.count() ; ++i ) {
+            CacheHTTPInfo* info = vector.get(i);
+            if (info && info->m_alt) alt_length += info->m_alt->m_unmarshal_len;
+          }
+          Note("OpenReadHead failed for cachekey %X : vector inconsistency - "
+               "unmarshalled %d expecting %d in %d (base=%d, flen=%d) "
+               "- vector n=%d size=%d"
+               "first alt=%d[%s]"
+               , key.word(0)
+               , uml, doc->hlen, doc->len, sizeofDoc, doc->_flen
+               , vector.count(), alt_length
+               , alt->m_magic
+               , (CACHE_ALT_MAGIC_ALIVE == alt->m_magic ? "alive"
+                  : CACHE_ALT_MAGIC_MARSHALED == alt->m_magic ? "serial"
+                  : CACHE_ALT_MAGIC_DEAD == alt->m_magic ? "dead"
+                  : "bogus")
+            );
           dir_delete(&key, vol, &dir);
         }
         err = ECACHE_BAD_META_DATA;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/aa191f82/proxy/hdrs/HTTP.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index b9b8dc6..4ce25c8 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -1520,28 +1520,30 @@ class UrlPrintHack {
       URLImpl* ui = hdr->m_url_cached.m_url_impl;
       char port_buff[10];
 
-      // Save values that can be modified.
-      m_hdr = hdr; // mark as having saved values.
-      m_len_host = ui->m_len_host;
-      m_ptr_host = ui->m_ptr_host;
-      m_len_port = ui->m_len_port;
-      m_ptr_port = ui->m_ptr_port;
+      m_hdr = hdr; // mark as potentially having modified values.
 
       /* Get dirty. We reach in to the URL implementation to
          set the host and port if
-         1) They are not already set and
-         2) The values were in a HTTP header field.
+         1) They are not already set
+         AND
+         2) The values were in a HTTP header.
       */
       if (!hdr->m_target_in_url && hdr->m_host_length && hdr->m_host_mime)
{
-        assert(0 == ui->m_ptr_host); // shouldn't be non-zero if not in URL.
+        ink_assert(0 == ui->m_ptr_host); // shouldn't be non-zero if not in URL.
         ui->m_ptr_host = hdr->m_host_mime->m_ptr_value;
         ui->m_len_host = hdr->m_host_length;
+        m_host_modified_p = true;
+      } else {
+        m_host_modified_p = false;
       }
 
       if (0 == hdr->m_url_cached.port_get_raw() && hdr->m_port_in_header) {
-        assert(0 == ui->m_ptr_port); // shouldn't be set if not in URL.
+        ink_assert(0 == ui->m_ptr_port); // shouldn't be set if not in URL.
         ui->m_ptr_port = port_buff;
         ui->m_len_port = sprintf(port_buff, "%.5d", hdr->m_port);
+        m_port_modified_p = true;
+      } else {
+        m_port_modified_p = false;
       }
     } else {
       m_hdr = 0;
@@ -1549,14 +1551,23 @@ class UrlPrintHack {
   }
 
   /// Destructor.
-  /// If we have a valid header, write the original URL values back.
   ~UrlPrintHack() {
-    if (m_hdr) {
+    if (m_hdr) { // There was a potentially modified header.
       URLImpl* ui = m_hdr->m_url_cached.m_url_impl;
-      ui->m_len_port = m_len_port;
-      ui->m_len_host = m_len_host;
-      ui->m_ptr_port = m_ptr_port;
-      ui->m_ptr_host = m_ptr_host;
+      // Because we only modified if not set, we can just set these values
+      // back to zero if modified. We want to be careful because if a
+      // heap re-allocation happened while this was active, then a saved value
+      // is wrong and will break things if restored. We don't have to worry
+      // about these because, if modified, they were originally NULL and should
+      // still be NULL after a re-allocate.
+      if (m_port_modified_p) {
+        ui->m_len_port = 0;
+        ui->m_ptr_port = 0;
+      }
+      if (m_host_modified_p) {
+        ui->m_len_host = 0;
+        ui->m_ptr_host = 0;
+      }
     }
   }
 
@@ -1567,10 +1578,8 @@ class UrlPrintHack {
    
   /// Saved values.
   ///@{
-  char const* m_ptr_host;
-  char const* m_ptr_port;
-  int m_len_host;
-  int m_len_port;
+  bool m_host_modified_p;
+  bool m_port_modified_p;
   HTTPHdr* m_hdr;
   ///@}
 };
@@ -1862,7 +1871,7 @@ HTTPInfo::marshal(char *buf, int len)
   buf += HTTP_ALT_MARSHAL_SIZE;
   used += HTTP_ALT_MARSHAL_SIZE;
 
-  if (frag_len) {
+  if (frag_len > 0) {
     marshal_alt->m_frag_offsets = static_cast<FragOffset*>(reinterpret_cast<void*>(used));
     memcpy(buf, m_alt->m_frag_offsets + HTTPCacheAlt::N_INTEGRAL_FRAG_OFFSETS, frag_len);
     buf += frag_len;


Mime
View raw message