Parcourir la source

[2850] Assert that the segment is not grown during allMemoryDeallocated()

JINMEI Tatuya il y a 12 ans
Parent
commit
67b935d7e7
1 fichiers modifiés avec 4 ajouts et 3 suppressions
  1. 4 3
      src/lib/util/memory_segment_mapped.cc

+ 4 - 3
src/lib/util/memory_segment_mapped.cc

@@ -137,7 +137,7 @@ struct MemorySegmentMapped::Impl {
         reserveMemory();
     }
 
-    void reserveMemory() {
+    void reserveMemory(bool no_grow = false) {
         if (!read_only_) {
             // Reserve a named address for use during
             // setNamedAddress(). Though this will almost always succeed
@@ -153,6 +153,7 @@ struct MemorySegmentMapped::Impl {
                 if (reserved_storage) {
                     break;
                 }
+                assert(!no_grow);
 
                 growSegment();
             }
@@ -332,8 +333,8 @@ MemorySegmentMapped::allMemoryDeallocated() const {
         impl_->freeReservedMemory();
         const bool result = impl_->base_sgmt_->all_memory_deallocated();
         // reserveMemory() should succeed now as the memory was already
-        // allocated.
-        impl_->reserveMemory();
+        // allocated, so we set no_grow to true.
+        impl_->reserveMemory(true);
         return (result);
     } catch (...) {
         abort();