@cryptotaxi247 / netdata-1 / commits / d228c6f32

Fix SIGSEGV on static installs due to dengine log (#19774)

* isolate the log from the validation * rewrite the log using a buffer * more x-ray vision replacements

Costa Tsaousis committed Mar 5, 2025 at 12:24 UTC d228c6f3265bf2049f94c3730c3876c9c949c0d4
4 files changed +91 -58
packaging/makeself/jobs/99-makeself.install.sh
+1 -1
@@ -93,7 +93,7 @@ run "${NETDATA_MAKESELF_PATH}/makeself.sh" \
93 --help-header "${NETDATA_MAKESELF_PATH}/makeself-help-header.txt" \
94 "${NETDATA_INSTALL_PATH}" \
95 "${NETDATA_INSTALL_PATH}.gz.run" \
96 - "netdata, the real-time performance and health monitoring system" \
96 + "Netdata, X-Ray Vision for your infrastructure" \
97 ./system/post-installer.sh
98
99 run rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
packaging/makeself/makeself.lsm
+1 -1
@@ -6,7 +6,7 @@ Description: netdata - X-Ray Vision for your infrastructure!
6 Per-second data collection, high-performance long-term storage, low-latency
7 visualization, machine-learning based anomaly detection, alerts and notifications,
8 advanced correlations and fast root cause analysis, native horizontal scalability.
9 -Keywords: real-time performance and health monitoring
9 +Keywords: X-Ray Vision for your infrastructure
10 Author: Netdata Inc.
11 Maintained-by: Netdata Inc.
12 Original-site: https://netdata.cloud/
src/database/engine/pdc.c
+88 -55
@@ -695,7 +695,92 @@ ALWAYS_INLINE VALIDATED_PAGE_DESCRIPTOR validate_extent_page_descr(const struct
695 "loaded", 0);
696 }
697
698 -ALWAYS_INLINE VALIDATED_PAGE_DESCRIPTOR validate_page(
698 +static void validate_page_log(nd_uuid_t *uuid,
699 + time_t start_time_s,
700 + time_t end_time_s,
701 + uint32_t update_every_s,
702 + size_t page_length,
703 + size_t entries,
704 + time_t now_s,
705 + const char *msg,
706 + RRDENG_COLLECT_PAGE_FLAGS flags,
707 + VALIDATED_PAGE_DESCRIPTOR vd) {
708 +#ifndef NETDATA_INTERNAL_CHECKS
709 + nd_log_limit_static_global_var(erl, 1, 0);
710 +#endif
711 + char uuid_str[UUID_STR_LEN + 1];
712 + uuid_unparse(*uuid, uuid_str);
713 +
714 + CLEAN_BUFFER *wb = NULL; // will be automatically freed on function exit
715 +
716 + if(flags) {
717 + wb = buffer_create(0, NULL);
718 + collect_page_flags_to_buffer(wb, flags);
719 + }
720 +
721 + if(!vd.is_valid) {
722 +#ifdef NETDATA_INTERNAL_CHECKS
723 + internal_error(true,
724 +#else
725 + nd_log_limit(&erl, NDLS_DAEMON, NDLP_ERR,
726 +#endif
727 + "DBENGINE: metric '%s' %s invalid page of type %u "
728 + "from %ld to %ld (now %ld), update every %u, page length %zu, entries %zu (flags: %s)",
729 + uuid_str, msg, (unsigned)vd.type,
730 + (long)vd.start_time_s, (long)vd.end_time_s, (long)now_s, (unsigned)vd.update_every_s, (size_t)vd.page_length, (size_t)vd.entries, wb?buffer_tostring(wb):""
731 + );
732 + }
733 + else {
734 + CLEAN_BUFFER *log = buffer_create(0, NULL);
735 +
736 + buffer_strcat(log, "DBENGINE: metric '");
737 + buffer_strcat(log, uuid_str);
738 + buffer_strcat(log, "' ");
739 + buffer_strcat(log, msg ? msg : "");
740 + buffer_strcat(log, " page of type ");
741 + buffer_print_uint64(log, vd.type);
742 + buffer_strcat(log, " from ");
743 + buffer_print_int64(log, vd.start_time_s);
744 + buffer_strcat(log, " to ");
745 + buffer_print_int64(log, vd.end_time_s);
746 + buffer_strcat(log, " (now ");
747 + buffer_print_int64(log, now_s);
748 + buffer_strcat(log, "), update every ");
749 + buffer_print_uint64(log, vd.update_every_s);
750 + buffer_strcat(log, ", page length ");
751 + buffer_print_uint64(log, vd.page_length);
752 + buffer_strcat(log, ", entries ");
753 + buffer_print_uint64(log, vd.entries);
754 + buffer_strcat(log, " (flags: ");
755 + buffer_strcat(log, wb ? buffer_tostring(wb) : "");
756 + buffer_strcat(log, ")");
757 + buffer_strcat(log, "found inconsistent - the right is ");
758 + buffer_print_int64(log, vd.start_time_s);
759 + buffer_strcat(log, " to ");
760 + buffer_print_int64(log, vd.end_time_s);
761 + buffer_strcat(log, ", update every ");
762 + buffer_print_uint64(log, vd.update_every_s);
763 + buffer_strcat(log, ", page length ");
764 + buffer_print_uint64(log, vd.page_length);
765 + buffer_strcat(log, ", entries ");
766 + buffer_print_uint64(log, vd.entries);
767 + buffer_strcat(log, (vd.start_time_s == start_time_s) ? "" : "start time updated, ");
768 + buffer_strcat(log, (vd.end_time_s == end_time_s) ? "" : "end time updated, ");
769 + buffer_strcat(log, (vd.update_every_s == update_every_s) ? "" : "update every updated, ");
770 + buffer_strcat(log, (vd.page_length == page_length) ? "" : "page length updated, ");
771 + buffer_strcat(log, (vd.entries == entries) ? "" : "entries updated, ");
772 + buffer_strcat(log, (now_s && vd.end_time_s <= now_s) ? "" : "future end time, ");
773 +
774 +#ifdef NETDATA_INTERNAL_CHECKS
775 + internal_error(true, "%s", buffer_tostring(log));
776 +#else
777 + nd_log_limit(&erl, NDLS_DAEMON, NDLP_ERR, "%s", buffer_tostring(log));
778 +#endif
779 + }
780 +}
781 +
782 +ALWAYS_INLINE
783 +VALIDATED_PAGE_DESCRIPTOR validate_page(
784 nd_uuid_t *uuid,
785 time_t start_time_s,
786 time_t end_time_s,
@@ -804,60 +889,8 @@ ALWAYS_INLINE VALIDATED_PAGE_DESCRIPTOR validate_page(
889 }
890 }
891
807 - if(unlikely(!vd.is_valid || updated)) {
808 -#ifndef NETDATA_INTERNAL_CHECKS
809 - nd_log_limit_static_global_var(erl, 1, 0);
810 -#endif
811 - char uuid_str[UUID_STR_LEN + 1];
812 - uuid_unparse(*uuid, uuid_str);
813 -
814 - BUFFER *wb = NULL;
815 -
816 - if(flags) {
817 - wb = buffer_create(0, NULL);
818 - collect_page_flags_to_buffer(wb, flags);
819 - }
820 -
821 - if(!vd.is_valid) {
822 -#ifdef NETDATA_INTERNAL_CHECKS
823 - internal_error(true,
824 -#else
825 - nd_log_limit(&erl, NDLS_DAEMON, NDLP_ERR,
826 -#endif
827 - "DBENGINE: metric '%s' %s invalid page of type %u "
828 - "from %ld to %ld (now %ld), update every %u, page length %zu, entries %zu (flags: %s)",
829 - uuid_str, msg, vd.type,
830 - vd.start_time_s, vd.end_time_s, now_s, vd.update_every_s, vd.page_length, vd.entries, wb?buffer_tostring(wb):""
831 - );
832 - }
833 - else {
834 - const char *err_valid = "";
835 - const char *err_start = (vd.start_time_s == start_time_s) ? "" : "start time updated, ";
836 - const char *err_end = (vd.end_time_s == end_time_s) ? "" : "end time updated, ";
837 - const char *err_update = (vd.update_every_s == update_every_s) ? "" : "update every updated, ";
838 - const char *err_length = (vd.page_length == page_length) ? "" : "page length updated, ";
839 - const char *err_entries = (vd.entries == entries) ? "" : "entries updated, ";
840 - const char *err_future = (now_s && vd.end_time_s <= now_s) ? "" : "future end time, ";
841 -
842 -#ifdef NETDATA_INTERNAL_CHECKS
843 - internal_error(true,
844 -#else
845 - nd_log_limit(&erl, NDLS_DAEMON, NDLP_ERR,
846 -#endif
847 - "DBENGINE: metric '%s' %s page of type %u "
848 - "from %ld to %ld (now %ld), update every %u, page length %zu, entries %zu (flags: %s), "
849 - "found inconsistent - the right is "
850 - "from %ld to %ld, update every %u, page length %zu, entries %zu: "
851 - "%s%s%s%s%s%s%s",
852 - uuid_str, msg, vd.type,
853 - start_time_s, end_time_s, now_s, update_every_s, page_length, entries, wb?buffer_tostring(wb):"",
854 - vd.start_time_s, vd.end_time_s, vd.update_every_s, vd.page_length, vd.entries,
855 - err_valid, err_start, err_end, err_update, err_length, err_entries, err_future
856 - );
857 - }
858 -
859 - buffer_free(wb);
860 - }
892 + if(unlikely(!vd.is_valid || updated))
893 + validate_page_log(uuid, start_time_s, end_time_s, update_every_s, page_length, entries, now_s, msg, flags, vd);
894
895 return vd;
896 }
src/health/notifications/alarm-notify.sh.in
+1 -1
@@ -3667,7 +3667,7 @@ Content-Transfer-Encoding: 8bit
3667 <tbody>
3668 <tr>
3669 <td align="left" style="font-size:0px;padding:10px 25px;padding-top:0;padding-bottom:0;word-break:break-word;">
3670 - <div style="font-family:Open Sans, sans-serif;font-size:13px;line-height:1;text-align:center;color:#35414A;">© Netdata $(date +'%Y') - The real-time performance and health monitoring</div>
3670 + <div style="font-family:Open Sans, sans-serif;font-size:13px;line-height:1;text-align:center;color:#35414A;">© Netdata $(date +'%Y') - X-Ray Vision for your infrastructure</div>
3671 </td>
3672 </tr>
3673 </tbody>