Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1939)

Unified Diff: third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.cc

Issue 7430007: Merge tcmalloc r111 (perftools v. 1.8) with the chromium/ branch. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.cc
===================================================================
--- third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.cc (revision 94429)
+++ third_party/tcmalloc/chromium/src/tests/system-alloc_unittest.cc (working copy)
@@ -40,6 +40,7 @@
#endif
#include <sys/types.h>
#include <algorithm>
+#include <limits>
#include "base/logging.h" // for Check_GEImpl, Check_LTImpl, etc
#include <google/malloc_extension.h> // for MallocExtension::instance
#include "common.h" // for kAddressBits
@@ -83,7 +84,6 @@
void DumpStats() {
}
- void FlagsInitialized() {}
private:
static const int kArraySize = 8 * 1024 * 1024;
@@ -115,14 +115,30 @@
const int kPointerBits = 8 * sizeof(void*);
const int kImplementedVirtualBits = NumImplementedVirtualBits();
- CHECK_GE(kAddressBits, min(kImplementedVirtualBits, kPointerBits));
+ CHECK_GE(kAddressBits, std::min(kImplementedVirtualBits, kPointerBits));
}
#endif
static void TestBasicRetryFailTest() {
// Check with the allocator still works after a failed allocation.
- void* p = malloc(1ULL << 50); // Asking for 1P ram
- CHECK(p == NULL);
+ //
+ // There is no way to call malloc and guarantee it will fail. malloc takes a
+ // size_t parameter and the C++ standard does not constrain the size of
+ // size_t. For example, consider an implementation where size_t is 32 bits
+ // and pointers are 64 bits.
+ //
+ // It is likely, though, that sizeof(size_t) == sizeof(void*). In that case,
+ // the first allocation here might succeed but the second allocation must
+ // fail.
+ //
+ // If the second allocation succeeds, you will have to rewrite or
+ // disable this test.
+ // The weird parens are to avoid macro-expansion of 'max' on windows.
+ const size_t kHugeSize = (std::numeric_limits<size_t>::max)() / 2;
+ void* p1 = malloc(kHugeSize);
+ void* p2 = malloc(kHugeSize);
+ CHECK(p2 == NULL);
+ if (p1 != NULL) free(p1);
char* q = new char[1024];
CHECK(q != NULL);

Powered by Google App Engine
This is Rietveld 408576698