Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/debug/asan_invalid_access.h" | 10 #include "base/debug/asan_invalid_access.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 namespace debug { | 15 namespace debug { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 #if defined(SYZYASAN) | 19 #if defined(SYZYASAN) && defined(COMPILER_MSVC) |
| 20 // Disable warning C4530: "C++ exception handler used, but unwind semantics are | 20 // Disable warning C4530: "C++ exception handler used, but unwind semantics are |
| 21 // not enabled". We don't want to change the compilation flags just for this | 21 // not enabled". We don't want to change the compilation flags just for this |
| 22 // test, and no exception should be triggered here, so this warning has no value | 22 // test, and no exception should be triggered here, so this warning has no value |
| 23 // here. | 23 // here. |
| 24 #pragma warning(push) | 24 #pragma warning(push) |
| 25 #pragma warning(disable: 4530) | 25 #pragma warning(disable: 4530) |
| 26 // Corrupt a memory block and make sure that the corruption gets detected either | 26 // Corrupt a memory block and make sure that the corruption gets detected either |
| 27 // when we free it or when another crash happens (if |induce_crash| is set to | 27 // when we free it or when another crash happens (if |induce_crash| is set to |
| 28 // true). | 28 // true). |
| 29 NOINLINE void CorruptMemoryBlock(bool induce_crash) { | 29 NOINLINE void CorruptMemoryBlock(bool induce_crash) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 // away. | 84 // away. |
| 85 int volatile dummy = 0; | 85 int volatile dummy = 0; |
| 86 int* dangling = array.get(); | 86 int* dangling = array.get(); |
| 87 array.reset(); | 87 array.reset(); |
| 88 dummy = dangling[kArraySize / 2]; | 88 dummy = dangling[kArraySize / 2]; |
| 89 base::debug::Alias(const_cast<int*>(&dummy)); | 89 base::debug::Alias(const_cast<int*>(&dummy)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 #endif // ADDRESS_SANITIZER || SYZYASAN | 92 #endif // ADDRESS_SANITIZER || SYZYASAN |
| 93 | 93 |
| 94 #if defined(SYZYASAN) | 94 #if defined(SYZYASAN) && defined(COMPILER_MSVC) |
| 95 void AsanCorruptHeapBlock() { | 95 void AsanCorruptHeapBlock() { |
| 96 CorruptMemoryBlock(false); | 96 CorruptMemoryBlock(false); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void AsanCorruptHeap() { | 99 void AsanCorruptHeap() { |
| 100 CorruptMemoryBlock(true); | 100 CorruptMemoryBlock(true); |
| 101 } | 101 } |
| 102 #endif // SYZYASAN | 102 #endif // SYZYASAN |
|
Nico
2014/07/30 16:50:38
nit: update?
| |
| 103 | 103 |
| 104 } // namespace debug | 104 } // namespace debug |
| 105 } // namespace base | 105 } // namespace base |
| OLD | NEW |