Changeset 294214 in webkit
- Timestamp:
- May 14, 2022 7:08:04 PM (2 years ago)
- Location:
- trunk/Source/bmalloc
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/bmalloc/ChangeLog
r293952 r294214 1 2022-05-14 Justin Michaud <justin_michaud@apple.com> 2 3 [LIBPAS] Add extra assert information to malloc enumeration API 4 https://bugs.webkit.org/show_bug.cgi?id=240292 5 6 Reviewed by Yusuke Suzuki. 7 8 In the heap enumerator (which is a slow path), we have asserts that 9 have the opportunity to include extra information to aid debugging. 10 11 We add PAS_ASSERT_WITH_DETAIL, which stuffs extra data into registers before crashing 12 so that we can see it in crash logs. We also add a debugging option to allow logging 13 to syslog, for cases when we do not have access to stdout. 14 15 * libpas/src/libpas/pas_enumerate_segregated_heaps.c: 16 (consider_allocator): 17 * libpas/src/libpas/pas_local_allocator_config_kind.h: 18 (pas_local_allocator_config_kind_create_normal): 19 (pas_local_allocator_config_kind_create_primordial_partial): 20 (pas_local_allocator_config_kind_create_bitfit): 21 (pas_local_allocator_config_kind_get_segregated_page_config_kind): 22 (pas_local_allocator_config_kind_get_bitfit_page_config_kind): 23 (pas_local_allocator_config_kind_get_string): 24 * libpas/src/libpas/pas_log.c: 25 (pas_vlog): 26 * libpas/src/libpas/pas_utils.c: 27 (pas_crash_with_info_impl): 28 (pas_panic): 29 (pas_assertion_failed_no_inline): 30 (pas_assertion_failed_no_inline_with_extra_detail): 31 * libpas/src/libpas/pas_utils.h: 32 1 33 2022-05-07 Mark Lam <mark.lam@apple.com> 2 34 -
trunk/Source/bmalloc/libpas/src/libpas/pas_enumerate_segregated_heaps.c
r291328 r294214 604 604 pas_log("Have allocator %p in page_ish = %p\n", allocator, (void*)allocator->page_ish); 605 605 606 PAS_ASSERT_WITH_ DETAIL(!pas_local_allocator_config_kind_is_bitfit(allocator->config_kind));606 PAS_ASSERT_WITH_EXTRA_DETAIL(!pas_local_allocator_config_kind_is_bitfit(allocator->config_kind), allocator->config_kind); 607 607 608 608 page_config = pas_segregated_page_config_kind_get_config( -
trunk/Source/bmalloc/libpas/src/libpas/pas_local_allocator_config_kind.h
r285789 r294214 87 87 #undef PAS_DEFINE_SEGREGATED_PAGE_CONFIG_KIND 88 88 } 89 PAS_ASSERT (!"Should not be reached");89 PAS_ASSERT_WITH_EXTRA_DETAIL(!"Should not be reached", kind); 90 90 return (pas_local_allocator_config_kind)0; 91 91 } … … 101 101 #undef PAS_DEFINE_SEGREGATED_PAGE_CONFIG_KIND 102 102 } 103 PAS_ASSERT (!"Should not be reached");103 PAS_ASSERT_WITH_EXTRA_DETAIL(!"Should not be reached", kind); 104 104 return (pas_local_allocator_config_kind)0; 105 105 } … … 115 115 #undef PAS_DEFINE_BITFIT_PAGE_CONFIG_KIND 116 116 } 117 PAS_ASSERT (!"Should not be reached");117 PAS_ASSERT_WITH_EXTRA_DETAIL(!"Should not be reached", kind); 118 118 return (pas_local_allocator_config_kind)0; 119 119 } … … 130 130 #undef PAS_DEFINE_SEGREGATED_PAGE_CONFIG_KIND 131 131 default: 132 PAS_ASSERT (!"Should not be reached");132 PAS_ASSERT_WITH_EXTRA_DETAIL(!"Should not be reached", kind); 133 133 return (pas_segregated_page_config_kind)0; 134 134 } … … 145 145 #undef PAS_DEFINE_BITFIT_PAGE_CONFIG_KIND 146 146 default: 147 PAS_ASSERT (!"Should not be reached");147 PAS_ASSERT_WITH_EXTRA_DETAIL(!"Should not be reached", kind); 148 148 return (pas_bitfit_page_config_kind)0; 149 149 } … … 171 171 #undef PAS_DEFINE_BITFIT_PAGE_CONFIG_KIND 172 172 } 173 PAS_ASSERT (!"Should not be reached");173 PAS_ASSERT_WITH_EXTRA_DETAIL(!"Should not be reached", kind); 174 174 return NULL; 175 175 } -
trunk/Source/bmalloc/libpas/src/libpas/pas_log.c
r284895 r294214 35 35 36 36 pthread_t pas_thread_that_is_crash_logging; 37 38 // Debug option to log to a file instead of stdout by default. 39 // This does not affect pas_fd_stream. 40 #define PAS_DEBUG_LOG_TO_SYSLOG 0 41 42 #if PAS_DEBUG_LOG_TO_SYSLOG 43 #include <sys/syslog.h> 44 #endif 37 45 38 46 void pas_vlog_fd(int fd, const char* format, va_list list) … … 85 93 void pas_vlog(const char* format, va_list list) 86 94 { 95 #if PAS_DEBUG_LOG_TO_SYSLOG 96 PAS_IGNORE_WARNINGS_BEGIN("format-nonliteral") 97 syslog(LOG_WARNING, format, list); 98 PAS_IGNORE_WARNINGS_END 99 #else 87 100 pas_vlog_fd(PAS_LOG_DEFAULT_FD, format, list); 101 #endif 88 102 } 89 103 -
trunk/Source/bmalloc/libpas/src/libpas/pas_utils.c
r291007 r294214 37 37 #include <unistd.h> 38 38 39 #if PAS_X86_64 40 41 #define CRASH_INST "int3" 42 43 #define CRASH_GPR0 "r11" 44 #define CRASH_GPR1 "r10" 45 #define CRASH_GPR2 "r9" 46 #define CRASH_GPR3 "r8" 47 #define CRASH_GPR4 "r15" 48 #define CRASH_GPR5 "r14" 49 #define CRASH_GPR6 "r13" 50 51 #elif PAS_ARM64 52 53 #define CRASH_INST "brk #0xc471" 54 55 #define CRASH_GPR0 "x16" 56 #define CRASH_GPR1 "x17" 57 #define CRASH_GPR2 "x18" 58 #define CRASH_GPR3 "x19" 59 #define CRASH_GPR4 "x20" 60 #define CRASH_GPR5 "x21" 61 #define CRASH_GPR6 "x22" 62 63 #endif 64 65 #if PAS_X86_64 || PAS_ARM64 66 67 PAS_NEVER_INLINE PAS_NO_RETURN static void pas_crash_with_info_impl(uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4, uint64_t misc5, uint64_t misc6) 68 { 69 register uint64_t reasonGPR asm(CRASH_GPR0) = reason; 70 register uint64_t misc1GPR asm(CRASH_GPR1) = misc1; 71 register uint64_t misc2GPR asm(CRASH_GPR2) = misc2; 72 register uint64_t misc3GPR asm(CRASH_GPR3) = misc3; 73 register uint64_t misc4GPR asm(CRASH_GPR4) = misc4; 74 register uint64_t misc5GPR asm(CRASH_GPR5) = misc5; 75 register uint64_t misc6GPR asm(CRASH_GPR6) = misc6; 76 __asm__ volatile (CRASH_INST : : "r"(reasonGPR), "r"(misc1GPR), "r"(misc2GPR), "r"(misc3GPR), "r"(misc4GPR), "r"(misc5GPR), "r"(misc6GPR)); 77 __builtin_trap(); 78 } 79 80 #else 81 82 PAS_NEVER_INLINE PAS_NO_RETURN static void pas_crash_with_info_impl(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t) { __builtin_trap(); } 83 84 #endif 85 39 86 void pas_panic(const char* format, ...) 40 87 { … … 45 92 va_start(arg_list, format); 46 93 pas_vlog(format, arg_list); 94 pas_crash_with_info_impl((uint64_t)format, 0, 0, 0, 0, 0, 0); 47 95 } 48 96 __builtin_trap(); … … 58 106 void pas_assertion_failed_no_inline(const char* filename, int line, const char* function, const char* expression) 59 107 { 60 pas_panic("%s:%d: %s: assertion %s failed.\n", filename, line, function, expression); 108 pas_log("[%d] pas assertion failed: ", getpid()); 109 pas_log("%s:%d: %s: assertion %s failed.\n", filename, line, function, expression); 110 pas_crash_with_info_impl((uint64_t)filename, line, (uint64_t) function, (uint64_t) expression, 0xbeefbff0, 42, 1337); 111 } 112 113 void pas_assertion_failed_no_inline_with_extra_detail(const char* filename, int line, const char* function, const char* expression, uint64_t extra) 114 { 115 pas_log("[%d] pas assertion failed (with extra detail): ", getpid()); 116 pas_log("%s:%d: %s: assertion %s failed. Extra data: %llu.\n", filename, line, function, expression, extra); 117 pas_crash_with_info_impl((uint64_t)filename, line, (uint64_t) function, (uint64_t) expression, extra, 1337, 0xbeef0bff); 61 118 } 62 119 -
trunk/Source/bmalloc/libpas/src/libpas/pas_utils.h
r293952 r294214 203 203 204 204 PAS_API PAS_NO_RETURN PAS_NEVER_INLINE void pas_assertion_failed_no_inline(const char* filename, int line, const char* function, const char* expression); 205 PAS_API PAS_NO_RETURN PAS_NEVER_INLINE void pas_assertion_failed_no_inline_with_extra_detail(const char* filename, int line, const char* function, const char* expression, uint64_t extra); 205 206 206 207 PAS_IGNORE_WARNINGS_BEGIN("missing-noreturn") … … 240 241 break; \ 241 242 pas_assertion_failed_no_inline(__FILE__, __LINE__, __PRETTY_FUNCTION__, #exp); \ 243 } while (0) 244 245 #define PAS_ASSERT_WITH_EXTRA_DETAIL(exp, extra) \ 246 do { \ 247 if (!PAS_ENABLE_ASSERT) \ 248 break; \ 249 if (PAS_LIKELY(exp)) \ 250 break; \ 251 pas_assertion_failed_no_inline_with_extra_detail(__FILE__, __LINE__, __PRETTY_FUNCTION__, #exp, extra); \ 242 252 } while (0) 243 253
Note: See TracChangeset
for help on using the changeset viewer.