@cryptotaxi247 / netdata-1 / commits / 3f689e6be

daemon status 26e (#20051)

do log the logger functions are root cause; always set the root cause function to something, so that we can easily find the stack traces

Costa Tsaousis committed Apr 4, 2025 at 01:37 UTC 3f689e6be784422e7d6e6acd0cd21f7811ee2ef6
1 file changed +7 -2
src/libnetdata/log/nd_log-stacktrace.c
+7 -2
@@ -72,7 +72,8 @@ static inline bool contains_logging_function(const char *text) {
72 static inline bool is_netdata_function(const char *function, const char *filename) {
73 return function && *function && filename && *filename &&
74 strstr(filename, "/src/") &&
75 - !strstr(filename, "/vendored/");
75 + !strstr(filename, "/vendored/") &&
76 + !contains_logging_function(function);
77 }
78
79 // Exact match check if a function is the signal handler (strcmp)
@@ -143,7 +144,7 @@ static void add_stack_frame(backtrace_data_t *bt_data, uintptr_t pc, const char
144 root_cause_function[0] = '\0';
145 return; // Skip adding the signal handler itself
146 }
146 -
147 +
148 // Check for logging functions, but only if we haven't found a signal handler yet
149 // This prevents double resets when crashing inside logging code
150 if (!bt_data->found_signal_handler && is_logging_function(function)) {
@@ -545,8 +546,12 @@ bool stack_trace_formatter(BUFFER *wb, void *data __maybe_unused) {
546 in_stack_trace = true;
547
548 root_cause_function[0] = '\0';
549 +
550 capture_stack_trace(wb);
551
552 + if(!root_cause_function[0])
553 + strncpyz(root_cause_function, "unknown_root_cause_function", sizeof(root_cause_function) - 1);
554 +
555 in_stack_trace = false; // Ensure the flag is reset
556 return true;
557 }