summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2024-01-11 19:57:17 +0200
committerGitHub <noreply@github.com>2024-01-11 19:57:17 +0200
commit989c856c5bd11c5c1c42b587541858ee992a1a5b (patch)
tree9466bccdd3572dcb63584edcacd43e7b99329b82
parent2165279a87314fb74e8c4de735231a78de73aa54 (diff)
Fix sanitizer errors (#16759)
* fix sanitizer errors in logs.c * fix sanitizer errors in rrdlabels.c * cleanup sanitizer exceptions
-rw-r--r--database/rrdlabels.c14
-rw-r--r--libnetdata/buffer/buffer.h5
-rw-r--r--libnetdata/dictionary/dictionary.c2
-rw-r--r--libnetdata/log/log.c22
4 files changed, 10 insertions, 33 deletions
diff --git a/database/rrdlabels.c b/database/rrdlabels.c
index c3ab51e226..d84d417146 100644
--- a/database/rrdlabels.c
+++ b/database/rrdlabels.c
@@ -694,11 +694,6 @@ static RRDLABEL *rrdlabels_find_label_with_key_unsafe(RRDLABELS *labels, RRDLABE
// ----------------------------------------------------------------------------
// rrdlabels_add()
-/*
- * FIXME: Attribute added because address sanitizer reports an issue when
- * running the agent with `-W unittest`.
-*/
-__attribute__((no_sanitize("address")))
static void labels_add_already_sanitized(RRDLABELS *labels, const char *key, const char *value, RRDLABEL_SRC ls)
{
RRDLABEL *new_label = add_label_name_value(key, value);
@@ -715,10 +710,13 @@ static void labels_add_already_sanitized(RRDLABELS *labels, const char *key, con
if(*PValue) {
new_ls |= RRDLABEL_FLAG_OLD;
+ *((RRDLABEL_SRC *)PValue) = new_ls;
+
delete_label(new_label);
}
else {
new_ls |= RRDLABEL_FLAG_NEW;
+ *((RRDLABEL_SRC *)PValue) = new_ls;
RRDLABEL *old_label_with_same_key = rrdlabels_find_label_with_key_unsafe(labels, new_label);
if (old_label_with_same_key) {
@@ -728,7 +726,6 @@ static void labels_add_already_sanitized(RRDLABELS *labels, const char *key, con
}
labels->version++;
- *((RRDLABEL_SRC *)PValue) = new_ls;
size_t mem_after_judyl = JudyLMemUsed(labels->JudyL);
STATS_PLUS_MEMORY(&dictionary_stats_category_rrdlabels, 0, mem_after_judyl - mem_before_judyl, 0);
@@ -1470,9 +1467,12 @@ static int rrdlabels_unittest_double_check()
rrdlabels_add(labels, "key1", "value1", RRDLABEL_SRC_CONFIG);
ret += rrdlabels_unittest_expect_value(labels, "key1", "value1", RRDLABEL_FLAG_NEW);
- rrdlabels_add(labels, "key1", "value2", RRDLABEL_SRC_CONFIG);
+ rrdlabels_add(labels, "key1", "value2", RRDLABEL_SRC_K8S);
ret += !rrdlabels_unittest_expect_value(labels, "key1", "value2", RRDLABEL_FLAG_OLD);
+ rrdlabels_add(labels, "key1", "value3", RRDLABEL_SRC_ACLK);
+ ret += !rrdlabels_unittest_expect_value(labels, "key1", "value3", RRDLABEL_FLAG_OLD);
+
ret += (rrdlabels_entries(labels) != 1);
rrdlabels_destroy(labels);
diff --git a/libnetdata/buffer/buffer.h b/libnetdata/buffer/buffer.h
index 25889f807d..bffcf6e1e4 100644
--- a/libnetdata/buffer/buffer.h
+++ b/libnetdata/buffer/buffer.h
@@ -279,11 +279,6 @@ static inline void buffer_memcat(BUFFER *wb, const void *mem, size_t bytes) {
buffer_overflow_check(wb);
}
-/*
- * FIXME: Attribute added because address sanitizer reports a log-related
- * issue when running the agent with `-W unittest`.
-*/
-__attribute__((no_sanitize("address")))
static inline void buffer_json_strcat(BUFFER *wb, const char *txt)
{
if(unlikely(!txt || !*txt)) return;
diff --git a/libnetdata/dictionary/dictionary.c b/libnetdata/dictionary/dictionary.c
index 0f5c3027a1..87975905c5 100644
--- a/libnetdata/dictionary/dictionary.c
+++ b/libnetdata/dictionary/dictionary.c
@@ -3803,6 +3803,8 @@ int dictionary_unittest(size_t entries) {
errors += dictionary_unittest_threads();
errors += dictionary_unittest_view_threads();
+ cleanup_destroyed_dictionaries();
+
fprintf(stderr, "\n%zu errors found\n", errors);
return errors ? 1 : 0;
}
diff --git a/libnetdata/log/log.c b/libnetdata/log/log.c
index f3b584d348..b93ef2cc29 100644
--- a/libnetdata/log/log.c
+++ b/libnetdata/log/log.c
@@ -1576,11 +1576,6 @@ static void priority_annotator(BUFFER *wb, const char *key, struct log_field *lf
buffer_strcat(wb, nd_log_id2priority(pri));
}
-/*
- * FIXME: Attribute added because address sanitizer reports a log-related
- * issue when running the agent with `-W unittest`.
-*/
-__attribute__((no_sanitize("address")))
static bool needs_quotes_for_logfmt(const char *s)
{
static bool safe_for_logfmt[256] = {
@@ -1613,11 +1608,6 @@ static bool needs_quotes_for_logfmt(const char *s)
return false;
}
-/*
- * FIXME: Attribute added because address sanitizer reports a log-related
- * issue when running the agent with `-W unittest`.
-*/
-__attribute__((no_sanitize("address")))
static void string_to_logfmt(BUFFER *wb, const char *s)
{
bool spaces = needs_quotes_for_logfmt(s);
@@ -1631,11 +1621,6 @@ static void string_to_logfmt(BUFFER *wb, const char *s)
buffer_fast_strcat(wb, "\"", 1);
}
-/*
- * FIXME: Attribute added because address sanitizer reports a log-related
- * issue when running the agent with `-W unittest`.
-*/
-__attribute__((no_sanitize("address")))
static void nd_logger_logfmt(BUFFER *wb, struct log_field *fields, size_t fields_max)
{
@@ -2170,8 +2155,8 @@ static void nd_logger(const char *file, const char *function, const unsigned lon
if(likely(!thread_log_fields[NDF_TID].entry.set))
thread_log_fields[NDF_TID].entry = ND_LOG_FIELD_U64(NDF_TID, gettid());
+ char os_threadname[NETDATA_THREAD_NAME_MAX + 1];
if(likely(!thread_log_fields[NDF_THREAD_TAG].entry.set)) {
- char os_threadname[NETDATA_THREAD_NAME_MAX + 1];
const char *thread_tag = netdata_thread_tag();
if(!netdata_thread_tag_exists()) {
if (!netdata_thread_tag_exists()) {
@@ -2260,11 +2245,6 @@ static ND_LOG_SOURCES nd_log_validate_source(ND_LOG_SOURCES source) {
// ----------------------------------------------------------------------------
// public API for loggers
-/*
- * FIXME: Attribute added because address sanitizer reports a log-related
- * issue when running the agent with `-W unittest`.
-*/
-__attribute__((no_sanitize("address")))
void netdata_logger(ND_LOG_SOURCES source, ND_LOG_FIELD_PRIORITY priority, const char *file, const char *function, unsigned long line, const char *fmt, ... )
{
int saved_errno = errno;