Revision: 10998
Author:   [email protected]
Date:     Sun Mar 11 08:04:50 2012
Log: V8 crashes when profile generator allocates a buffer for HeapEntry'es bigger than 2Gb.

BUG=none
TEST=profile-generator tests

Review URL: https://chromiumcodereview.appspot.com/9632020
http://code.google.com/p/v8/source/detail?r=10998

Modified:
 /branches/bleeding_edge/src/allocation.h
 /branches/bleeding_edge/src/profile-generator.cc
 /branches/bleeding_edge/src/profile-generator.h

=======================================
--- /branches/bleeding_edge/src/allocation.h    Wed Jan 25 08:31:25 2012
+++ /branches/bleeding_edge/src/allocation.h    Sun Mar 11 08:04:50 2012
@@ -80,7 +80,7 @@


 template <typename T>
-T* NewArray(int size) {
+T* NewArray(size_t size) {
   T* result = new T[size];
   if (result == NULL) Malloced::FatalProcessOutOfMemory();
   return result;
=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Sat Mar 10 23:35:21 2012 +++ /branches/bleeding_edge/src/profile-generator.cc Sun Mar 11 08:04:50 2012
@@ -1096,9 +1096,9 @@
 }


-int HeapEntry::EntriesSize(int entries_count,
-                           int children_count,
-                           int retainers_count) {
+size_t HeapEntry::EntriesSize(int entries_count,
+                              int children_count,
+                              int retainers_count) {
   return sizeof(HeapEntry) * entries_count         // NOLINT
       + sizeof(HeapGraphEdge) * children_count     // NOLINT
       + sizeof(HeapGraphEdge*) * retainers_count;  // NOLINT
@@ -1114,13 +1114,14 @@
 template <> struct SnapshotSizeConstants<4> {
   static const int kExpectedHeapGraphEdgeSize = 12;
   static const int kExpectedHeapEntrySize = 36;
-  static const int kMaxSerializableSnapshotRawSize = 256 * MB;
+  static const size_t kMaxSerializableSnapshotRawSize = 256 * MB;
 };

 template <> struct SnapshotSizeConstants<8> {
   static const int kExpectedHeapGraphEdgeSize = 24;
   static const int kExpectedHeapEntrySize = 48;
-  static const int kMaxSerializableSnapshotRawSize = 768 * MB;
+  static const uint64_t kMaxSerializableSnapshotRawSize =
+      static_cast<uint64_t>(6000) * MB;
 };

 }  // namespace
@@ -3437,8 +3438,8 @@
   HeapEntry* root = result->AddRootEntry(1);
   const char* text = snapshot_->collection()->names()->GetFormatted(
       "The snapshot is too big. "
-      "Maximum snapshot size is %d MB. "
-      "Actual snapshot size is %d MB.",
+      "Maximum snapshot size is %"  V8_PTR_PREFIX "u MB. "
+      "Actual snapshot size is %"  V8_PTR_PREFIX "u MB.",
SnapshotSizeConstants<kPointerSize>::kMaxSerializableSnapshotRawSize / MB,
       (snapshot_->raw_entries_size() + MB - 1) / MB);
   HeapEntry* message = result->AddEntry(
=======================================
--- /branches/bleeding_edge/src/profile-generator.h     Sat Mar 10 23:35:21 2012
+++ /branches/bleeding_edge/src/profile-generator.h     Sun Mar 11 08:04:50 2012
@@ -577,16 +577,18 @@
                          int retainer_index);
void SetUnidirElementReference(int child_index, int index, HeapEntry* entry);

- int EntrySize() { return EntriesSize(1, children_count_, retainers_count_); }
+  size_t EntrySize() {
+    return EntriesSize(1, children_count_, retainers_count_);
+  }

   void Print(
const char* prefix, const char* edge_name, int max_depth, int indent);

   Handle<HeapObject> GetHeapObject();

-  static int EntriesSize(int entries_count,
-                         int children_count,
-                         int retainers_count);
+  static size_t EntriesSize(int entries_count,
+                            int children_count,
+                            int retainers_count);

  private:
   HeapGraphEdge* children_arr() {
@@ -647,7 +649,7 @@
   HeapEntry* natives_root() { return natives_root_entry_; }
   HeapEntry* gc_subroot(int index) { return gc_subroot_entries_[index]; }
   List<HeapEntry*>* entries() { return &entries_; }
-  int raw_entries_size() { return raw_entries_size_; }
+  size_t raw_entries_size() { return raw_entries_size_; }

   void AllocateEntries(
       int entries_count, int children_count, int retainers_count);
@@ -687,7 +689,7 @@
   char* raw_entries_;
   List<HeapEntry*> entries_;
   bool entries_sorted_;
-  int raw_entries_size_;
+  size_t raw_entries_size_;

   friend class HeapSnapshotTester;

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to