Ken Russell | 538bdbc | 2018-01-25 18:13:07 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/renderer/crash_helpers.h" |
| 6 | |
| 7 | #include "base/debug/alias.h" |
| 8 | |
| 9 | namespace content { |
| 10 | |
| 11 | namespace internal { |
| 12 | |
| 13 | NOINLINE void CrashIntentionally() { |
| 14 | // NOTE(shess): Crash directly rather than using NOTREACHED() so |
| 15 | // that the signature is easier to triage in crash reports. |
| 16 | // |
| 17 | // Linker's ICF feature may merge this function with other functions with the |
| 18 | // same definition and it may confuse the crash report processing system. |
| 19 | static int static_variable_to_make_this_function_unique = 0; |
| 20 | base::debug::Alias(&static_variable_to_make_this_function_unique); |
| 21 | |
| 22 | volatile int* zero = nullptr; |
| 23 | *zero = 0; |
| 24 | } |
| 25 | |
| 26 | NOINLINE void BadCastCrashIntentionally() { |
| 27 | class A { |
| 28 | virtual void f() {} |
| 29 | }; |
| 30 | |
| 31 | class B { |
| 32 | virtual void f() {} |
| 33 | }; |
| 34 | |
| 35 | A a; |
| 36 | (void)(B*) & a; |
| 37 | } |
| 38 | |
| 39 | } // namespace internal |
| 40 | |
| 41 | } // namespace content |