OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <limits> | 5 #include <limits> |
6 #include <sstream> | 6 #include <sstream> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 | 129 |
130 // The test is used for manual testing, e.g., to see the raw output. | 130 // The test is used for manual testing, e.g., to see the raw output. |
131 TEST_F(StackTraceTest, DebugPrintBacktrace) { | 131 TEST_F(StackTraceTest, DebugPrintBacktrace) { |
132 StackTrace().Print(); | 132 StackTrace().Print(); |
133 } | 133 } |
134 #endif // !defined(__UCLIBC__) | 134 #endif // !defined(__UCLIBC__) |
135 | 135 |
136 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 136 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
137 #if !defined(OS_IOS) | 137 #if !defined(OS_IOS) |
| 138 static char* newArray() { |
| 139 // Clang warns about the mismatched new[]/delete if they occur in the same |
| 140 // function. |
| 141 return new char[10]; |
| 142 } |
| 143 |
138 MULTIPROCESS_TEST_MAIN(MismatchedMallocChildProcess) { | 144 MULTIPROCESS_TEST_MAIN(MismatchedMallocChildProcess) { |
139 char* pointer = new char[10]; | 145 char* pointer = newArray(); |
140 delete pointer; | 146 delete pointer; |
141 return 2; | 147 return 2; |
142 } | 148 } |
143 | 149 |
144 // Regression test for StackDumpingSignalHandler async-signal unsafety. | 150 // Regression test for StackDumpingSignalHandler async-signal unsafety. |
145 // Combined with tcmalloc's debugallocation, that signal handler | 151 // Combined with tcmalloc's debugallocation, that signal handler |
146 // and e.g. mismatched new[]/delete would cause a hang because | 152 // and e.g. mismatched new[]/delete would cause a hang because |
147 // of re-entering malloc. | 153 // of re-entering malloc. |
148 TEST_F(StackTraceTest, AsyncSignalUnsafeSignalHandlerHang) { | 154 TEST_F(StackTraceTest, AsyncSignalUnsafeSignalHandlerHang) { |
149 Process child = SpawnChild("MismatchedMallocChildProcess"); | 155 Process child = SpawnChild("MismatchedMallocChildProcess"); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 1)); | 230 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 1)); |
225 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 2)); | 231 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 2)); |
226 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 3)); | 232 EXPECT_EQ("688", itoa_r_wrapper(0x688, 128, 16, 3)); |
227 EXPECT_EQ("0688", itoa_r_wrapper(0x688, 128, 16, 4)); | 233 EXPECT_EQ("0688", itoa_r_wrapper(0x688, 128, 16, 4)); |
228 EXPECT_EQ("00688", itoa_r_wrapper(0x688, 128, 16, 5)); | 234 EXPECT_EQ("00688", itoa_r_wrapper(0x688, 128, 16, 5)); |
229 } | 235 } |
230 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) | 236 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) |
231 | 237 |
232 } // namespace debug | 238 } // namespace debug |
233 } // namespace base | 239 } // namespace base |
OLD | NEW |