ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
asan.c
Go to the documentation of this file.
1
31#include <ascii-chat/log/log.h>
32
33// Clang on macOS/Linux uses __has_feature(address_sanitizer).
34// Clang on Windows and GCC define __SANITIZE_ADDRESS__ instead.
35#if defined(__has_feature)
36#if __has_feature(address_sanitizer)
37#define HAS_ASAN 1
38#endif
39#endif
40#if !defined(HAS_ASAN) && defined(__SANITIZE_ADDRESS__)
41#define HAS_ASAN 1
42#endif
43
44#ifdef HAS_ASAN
45#include <sanitizer/asan_interface.h>
46
63static void asan_error_report_callback(const char *report) {
64 if (!report) {
65 return;
66 }
67
68 // Feed the entire report through the logging system
69 // This respects --log-file, --grep, and other logging filters
70 log_fatal("AddressSanitizer detected memory error:\n%s", report);
71
72 // Note: log_fatal will abort the process, so we won't return from here
73}
74
84__attribute__((constructor)) static void init_asan_error_reporting(void) {
85 __asan_set_error_report_callback(asan_error_report_callback);
86}
87
88#endif // HAS_ASAN
#define log_fatal(...)
Log a FATAL message.
Definition log/log.h:599
📝 Logging API with multiple log levels and terminal output control
Network quality metrics for a single participant.
Definition metrics.h:33