MCPcopy Create free account
hub / github.com/crownengine/crown / crash

Function crash

src/core/debug/debug.cpp:35–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 }
34
35 void crash(CrashType::Enum type)
36 {
37 CE_ALIGN_DECL(alignof(s64), u8 buf[16]);
38 volatile s64 zero = 0;
39
40 switch (type) {
41 case CrashType::DIVISION_BY_ZERO:
42 *((f32 *)buf) = 1.0f / f32(zero);
43 break;
44
45 case CrashType::UNALIGNED_ACCESS:
46 *((s64 *)&buf[1]) = zero;
47 break;
48
49 case CrashType::SEGMENTATION_FAULT:
50 *((s64 *)(uintptr_t)0xffffffffu) = zero;
51 break;
52
53 case CrashType::OUT_OF_MEMORY: {
54 s64 size = 512*1024*1024;
55 for (s64 i = 0; i < INT64_MAX; ++i, size *= 2)
56 *((s64 *)default_allocator().allocate(u32(size))) = zero;
57 break;
58 }
59
60 case CrashType::ASSERT:
61 CE_ASSERT(false, "False");
62 break;
63
64 default:
65 break;
66 }
67 }
68
69} // namespace debug
70

Callers 1

device_command_crashFunction · 0.85

Calls 1

allocateMethod · 0.45

Tested by

no test coverage detected