Bug 693928: Fix random orange from LifoAlloc debug memset. (r=luke)
authorChris Leary <cdleary@mozilla.com>
Wed, 12 Oct 2011 15:32:40 -0700
changeset 78646 fe8302fd1c83
parent 78645 ccf5c0a8c37b
child 78647 366efc04fd3c
push id2620
push usercleary@mozilla.com
push date2011-10-12 22:35 +0000
treeherdermozilla-inbound@fe8302fd1c83 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs693928
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 693928: Fix random orange from LifoAlloc debug memset. (r=luke)
js/src/ds/LifoAlloc.h
mfbt/Util.h
--- a/js/src/ds/LifoAlloc.h
+++ b/js/src/ds/LifoAlloc.h
@@ -87,29 +87,28 @@ class BumpChunk
     explicit BumpChunk(size_t bumpSpaceSize)
       : bump(reinterpret_cast<char *>(thisDuringConstruction()) + sizeof(BumpChunk)),
         limit(bump + bumpSpaceSize),
         next_(NULL), bumpSpaceSize(bumpSpaceSize)
     {
         JS_ASSERT(bump == AlignPtr(bump));
     }
 
-    void clobberUnused() {
-#ifdef DEBUG
-        memset(bump, 0xcd, limit - bump);
-#endif
-    }
-
     void setBump(void *ptr) {
         JS_ASSERT(bumpBase() <= ptr);
         JS_ASSERT(ptr <= limit);
         DebugOnly<char *> prevBump = bump;
         bump = static_cast<char *>(ptr);
-        if (prevBump < bump)
-            clobberUnused();
+#ifdef DEBUG
+        JS_ASSERT(contains(prevBump));
+
+        /* Clobber the now-free space. */
+        if (prevBump > bump)
+            memset(bump, 0xcd, prevBump - bump);
+#endif
     }
 
   public:
     BumpChunk *next() const { return next_; }
     void setNext(BumpChunk *succ) { next_ = succ; }
 
     size_t used() const { return bump - bumpBase(); }
 
--- a/mfbt/Util.h
+++ b/mfbt/Util.h
@@ -172,25 +172,22 @@ struct DebugOnly
         value--;
     }
 
     operator T&() { return value; }
     operator const T&() const { return value; }
 
     T& operator->() { return value; }
 
-    bool operator<(const T& other) { return value < other; }
-
 #else
     DebugOnly() {}
     DebugOnly(const T&) {}
     DebugOnly& operator=(const T&) { return *this; }
     void operator++(int) {}
     void operator--(int) {}
-    bool operator<(const T&) { return false; }
 #endif
 
     /*
      * DebugOnly must always have a destructor or else it will
      * generate "unused variable" warnings, exactly what it's intended
      * to avoid!
      */
     ~DebugOnly() {}