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

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

Issue 26145004: 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.
79 // The wrapper function in base/process_util_linux.cc that is used when we 78 // The wrapper function in base/process_util_linux.cc that is used when we
80 // compile without TCMalloc will just die on OOM instead of returning NULL. 79 // compile without TCMalloc will just die on OOM instead of returning NULL.
81 #if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \ 80 // This function is explicitly disabled if we compile with AddressSanitizer,
82 defined(THREAD_SANITIZER) || (defined(OS_LINUX) && defined(NO_TCMALLOC)) 81 // MemorySanitizer or ThreadSanitizer.
82 #if defined(OS_LINUX) && defined(NO_TCMALLOC) && \
83 (!defined(ADDRESS_SANITIZER) && \
84 !defined(MEMORY_SANITIZER) && \
85 !defined(THREAD_SANITIZER))
83 return true; 86 return true;
84 #else 87 #else
85 return false; 88 return false;
86 #endif 89 #endif
87 } 90 }
88 91
89 // Fake test that allow to know the state of TCMalloc by looking at bots. 92 // Fake test that allow to know the state of TCMalloc by looking at bots.
90 TEST(SecurityTest, TCMALLOC_TEST(IsTCMallocDynamicallyBypassed)) { 93 TEST(SecurityTest, TCMALLOC_TEST(IsTCMallocDynamicallyBypassed)) {
91 printf("Malloc is dynamically bypassed: %s\n", 94 printf("Malloc is dynamically bypassed: %s\n",
92 IsTcMallocBypassed() ? "yes." : "no."); 95 IsTcMallocBypassed() ? "yes." : "no.");
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // kRandomMask, so we use it as an additional detection mechanism. 297 // kRandomMask, so we use it as an additional detection mechanism.
295 const uintptr_t kRandomMask = 0x3fffffffffffULL; 298 const uintptr_t kRandomMask = 0x3fffffffffffULL;
296 bool impossible_random_address = 299 bool impossible_random_address =
297 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; 300 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask;
298 EXPECT_FALSE(impossible_random_address); 301 EXPECT_FALSE(impossible_random_address);
299 } 302 }
300 303
301 #endif // (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__x86_64__) 304 #endif // (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__x86_64__)
302 305
303 } // namespace 306 } // 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