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

Side by Side Diff: base/security_unittest.cc

Issue 13061002: Make CallocDiesOnOOM return false under TSan and ASan. Their allocators return NULL in the case of … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 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 | « no previous file | no next file » | 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 char* g_slice = getenv("G_SLICE"); 59 char* g_slice = getenv("G_SLICE");
60 if (g_slice && !strcmp(g_slice, "always-malloc")) 60 if (g_slice && !strcmp(g_slice, "always-malloc"))
61 return true; 61 return true;
62 #endif 62 #endif
63 return false; 63 return false;
64 } 64 }
65 65
66 bool CallocDiesOnOOM() { 66 bool CallocDiesOnOOM() {
67 // The wrapper function in base/process_util_linux.cc that is used when we 67 // The wrapper function in base/process_util_linux.cc that is used when we
68 // compile without TCMalloc will just die on OOM instead of returning NULL. 68 // compile without TCMalloc will just die on OOM instead of returning NULL.
69 #if defined(OS_LINUX) && defined(NO_TCMALLOC) 69 // This function is explicitly disabled if we compile with AddressSanitizer,
70 // MemorySanitizer or ThreadSanitizer.
71 #if defined(OS_LINUX) && defined(NO_TCMALLOC) && \
72 (!defined(ADDRESS_SANITIZER) && \
73 !defined(MEMORY_SANITIZER) && \
74 !defined(THREAD_SANITIZER))
70 return true; 75 return true;
71 #else 76 #else
72 return false; 77 return false;
73 #endif 78 #endif
74 } 79 }
75 80
76 // Fake test that allow to know the state of TCMalloc by looking at bots. 81 // Fake test that allow to know the state of TCMalloc by looking at bots.
77 TEST(SecurityTest, TCMALLOC_TEST(IsTCMallocDynamicallyBypassed)) { 82 TEST(SecurityTest, TCMALLOC_TEST(IsTCMallocDynamicallyBypassed)) {
78 printf("Malloc is dynamically bypassed: %s\n", 83 printf("Malloc is dynamically bypassed: %s\n",
79 IsTcMallocBypassed() ? "yes." : "no."); 84 IsTcMallocBypassed() ? "yes." : "no.");
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // kRandomMask, so we use it as an additional detection mechanism. 293 // kRandomMask, so we use it as an additional detection mechanism.
289 const uintptr_t kRandomMask = 0x3fffffffffffULL; 294 const uintptr_t kRandomMask = 0x3fffffffffffULL;
290 bool impossible_random_address = 295 bool impossible_random_address =
291 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask; 296 reinterpret_cast<uintptr_t>(ptr.get()) & ~kRandomMask;
292 EXPECT_FALSE(impossible_random_address); 297 EXPECT_FALSE(impossible_random_address);
293 } 298 }
294 299
295 #endif // (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__x86_64__) 300 #endif // (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(__x86_64__)
296 301
297 } // namespace 302 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698