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

Side by Side Diff: trunk/src/base/security_unittest.cc

Issue 25999003: Revert 226978 "Revert 226920 "Roll Clang 188423:191856."" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/base/debug/stack_trace_android.cc ('k') | trunk/src/build/common.gypi » ('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 <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // This should detect a TCMalloc bypass from setting 68 // This should detect a TCMalloc bypass from setting
69 // the CHROME_ALLOCATOR environment variable. 69 // the CHROME_ALLOCATOR environment variable.
70 char* allocator = getenv("CHROME_ALLOCATOR"); 70 char* allocator = getenv("CHROME_ALLOCATOR");
71 if (allocator && strcmp(allocator, "tcmalloc")) 71 if (allocator && strcmp(allocator, "tcmalloc"))
72 return true; 72 return true;
73 #endif 73 #endif
74 return false; 74 return false;
75 } 75 }
76 76
77 bool CallocDiesOnOOM() { 77 bool CallocDiesOnOOM() {
78 // The sanitizers' calloc dies on OOM instead of returning NULL.
78 // The wrapper function in base/process_util_linux.cc that is used when we 79 // The wrapper function in base/process_util_linux.cc that is used when we
79 // compile without TCMalloc will just die on OOM instead of returning NULL. 80 // compile without TCMalloc will just die on OOM instead of returning NULL.
80 // This function is explicitly disabled if we compile with AddressSanitizer, 81 #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
81 // MemorySanitizer or ThreadSanitizer. 82 defined(THREAD_SANITIZER) || (defined(OS_LINUX) && defined(NO_TCMALLOC))
82 #if defined(OS_LINUX) && defined(NO_TCMALLOC) && \
83 (!defined(ADDRESS_SANITIZER) && \
84 !defined(MEMORY_SANITIZER) && \
85 !defined(THREAD_SANITIZER))
86 return true; 83 return true;
87 #else 84 #else
88 return false; 85 return false;
89 #endif 86 #endif
90 } 87 }
91 88
92 // Fake test that allow to know the state of TCMalloc by looking at bots. 89 // Fake test that allow to know the state of TCMalloc by looking at bots.
93 TEST(SecurityTest, TCMALLOC_TEST(IsTCMallocDynamicallyBypassed)) { 90 TEST(SecurityTest, TCMALLOC_TEST(IsTCMallocDynamicallyBypassed)) {
94 printf("Malloc is dynamically bypassed: %s\n", 91 printf("Malloc is dynamically bypassed: %s\n",
95 IsTcMallocBypassed() ? "yes." : "no."); 92 IsTcMallocBypassed() ? "yes." : "no.");
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // kRandomMask, so we use it as an additional detection mechanism. 300 // kRandomMask, so we use it as an additional detection mechanism.
304 const uintptr_t kRandomMask = 0x3fffffffffffULL; 301 const uintptr_t kRandomMask = 0x3fffffffffffULL;
305 bool impossible_random_address = 302 bool impossible_random_address =
306 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; 303 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask;
307 EXPECT_FALSE(impossible_random_address); 304 EXPECT_FALSE(impossible_random_address);
308 } 305 }
309 306
310 #endif // (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__x86_64__) 307 #endif // (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__x86_64__)
311 308
312 } // namespace 309 } // namespace
OLDNEW
« no previous file with comments | « trunk/src/base/debug/stack_trace_android.cc ('k') | trunk/src/build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698