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

Side by Side Diff: base/security_unittest.cc

Issue 2907563002: allocator/Windows: delete the old non-unified allocator-shim (Closed)
Patch Set: remove comment Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « base/process/memory_unittest.cc ('k') | build/config/allocator.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <fcntl.h> 5 #include <fcntl.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <limits> 14 #include <limits>
15 #include <memory> 15 #include <memory>
16 16
17 #include "base/allocator/features.h"
17 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/memory/free_deleter.h" 20 #include "base/memory/free_deleter.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 #if defined(OS_POSIX) 24 #if defined(OS_POSIX)
24 #include <sys/mman.h> 25 #include <sys/mman.h>
25 #include <unistd.h> 26 #include <unistd.h>
26 #endif 27 #endif
(...skipping 10 matching lines...) Expand all
37 template <typename Type> 38 template <typename Type>
38 NOINLINE Type HideValueFromCompiler(volatile Type value) { 39 NOINLINE Type HideValueFromCompiler(volatile Type value) {
39 #if defined(__GNUC__) 40 #if defined(__GNUC__)
40 // In a GCC compatible compiler (GCC or Clang), make this compiler barrier 41 // In a GCC compatible compiler (GCC or Clang), make this compiler barrier
41 // more robust than merely using "volatile". 42 // more robust than merely using "volatile".
42 __asm__ volatile ("" : "+r" (value)); 43 __asm__ volatile ("" : "+r" (value));
43 #endif // __GNUC__ 44 #endif // __GNUC__
44 return value; 45 return value;
45 } 46 }
46 47
47 // Tcmalloc and Windows allocator shim support setting malloc limits. 48 // TCmalloc, currently supported only by Linux/CrOS, supports malloc limits.
48 // - NO_TCMALLOC (should be defined if compiled with use_allocator!="tcmalloc") 49 // - NO_TCMALLOC (should be defined if compiled with use_allocator!="tcmalloc")
49 // - ADDRESS_SANITIZER and SYZYASAN because they have their own memory allocator 50 // - ADDRESS_SANITIZER it has its own memory allocator
50 // - IOS does not use tcmalloc 51 #if defined(OS_LINUX) && !defined(NO_TCMALLOC) && !defined(ADDRESS_SANITIZER)
51 // - OS_MACOSX does not use tcmalloc
52 // - Windows allocator shim defines ALLOCATOR_SHIM
53 #if (!defined(NO_TCMALLOC) || defined(ALLOCATOR_SHIM)) && \
54 !defined(ADDRESS_SANITIZER) && !defined(OS_IOS) && !defined(OS_MACOSX) && \
55 !defined(SYZYASAN)
56 #define MALLOC_OVERFLOW_TEST(function) function 52 #define MALLOC_OVERFLOW_TEST(function) function
57 #else 53 #else
58 #define MALLOC_OVERFLOW_TEST(function) DISABLED_##function 54 #define MALLOC_OVERFLOW_TEST(function) DISABLED_##function
59 #endif 55 #endif
60 56
61 #if defined(OS_LINUX) && defined(__x86_64__) 57 #if defined(OS_LINUX) && defined(__x86_64__)
62 // Detect runtime TCMalloc bypasses. 58 // Detect runtime TCMalloc bypasses.
63 bool IsTcMallocBypassed() { 59 bool IsTcMallocBypassed() {
64 // This should detect a TCMalloc bypass from Valgrind. 60 // This should detect a TCMalloc bypass from Valgrind.
65 char* g_slice = getenv("G_SLICE"); 61 char* g_slice = getenv("G_SLICE");
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // kRandomMask, so we use it as an additional detection mechanism. 175 // kRandomMask, so we use it as an additional detection mechanism.
180 const uintptr_t kRandomMask = 0x3fffffffffffULL; 176 const uintptr_t kRandomMask = 0x3fffffffffffULL;
181 bool impossible_random_address = 177 bool impossible_random_address =
182 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; 178 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask;
183 EXPECT_FALSE(impossible_random_address); 179 EXPECT_FALSE(impossible_random_address);
184 } 180 }
185 181
186 #endif // defined(OS_LINUX) && defined(__x86_64__) 182 #endif // defined(OS_LINUX) && defined(__x86_64__)
187 183
188 } // namespace 184 } // namespace
OLDNEW
« no previous file with comments | « base/process/memory_unittest.cc ('k') | build/config/allocator.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698