Reviewers: Yang,

Message:
This leaves FLAG_max_semi_space_size untouched because it's an int. I assume
that's because it's not expected to be ever larger than a few MB?

A related issue is the ResourceConstraints class in include/v8.h. Because it
uses ints, you can't create an isolate with a heap > 2 GB.  I didn't address
that here because it constitutes an ABI change and I'm not sure what the policy
on that is.

Description:
Fix --max_old_space_size=4096 integer overflow.

BUG=v8:3857

Please review this at https://codereview.chromium.org/897543002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+5, -4 lines):
  M src/heap/heap.cc


Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 52bd70a7527afdd53eac21a8288d01e9966a56f2..b247ff8018444e7bc750c2cb5d88ff8eee71902d 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -5108,10 +5108,10 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
     max_semi_space_size_ = max_semi_space_size * MB;
   }
   if (max_old_space_size > 0) {
-    max_old_generation_size_ = max_old_space_size * MB;
+ max_old_generation_size_ = static_cast<intptr_t>(max_old_space_size) * MB;
   }
   if (max_executable_size > 0) {
-    max_executable_size_ = max_executable_size * MB;
+    max_executable_size_ = static_cast<intptr_t>(max_executable_size) * MB;
   }

   // If max space size flags are specified overwrite the configuration.
@@ -5119,10 +5119,11 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
     max_semi_space_size_ = FLAG_max_semi_space_size * MB;
   }
   if (FLAG_max_old_space_size > 0) {
-    max_old_generation_size_ = FLAG_max_old_space_size * MB;
+    max_old_generation_size_ =
+        static_cast<intptr_t>(FLAG_max_old_space_size) * MB;
   }
   if (FLAG_max_executable_size > 0) {
-    max_executable_size_ = FLAG_max_executable_size * MB;
+ max_executable_size_ = static_cast<intptr_t>(FLAG_max_executable_size) * MB;
   }

   if (FLAG_stress_compaction) {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to