@cryptotaxi247 / netdata-1 / commits / cac1e1f30

fix thread name on fatal and cgroup netdev rename crash (#16771)

* fix thread name on fatal * fix cgroup missing reference counter dup

Costa Tsaousis committed Jan 12, 2024 at 15:56 UTC cac1e1f30b832fb7000107ba82dfadcf509281ee
2 files changed +20 -10
collectors/cgroups.plugin/cgroup-top.c
+10 -9
@@ -15,17 +15,17 @@ void cgroup_netdev_link_init(void) {
15 }
16
17 const DICTIONARY_ITEM *cgroup_netdev_get(struct cgroup *cg) {
18 - if(cg->cgroup_netdev_link)
19 - return cg->cgroup_netdev_link;
20 -
21 -
22 - struct cgroup_netdev_link t = {
18 + if(!cg->cgroup_netdev_link) {
19 + struct cgroup_netdev_link t = {
20 .read_slot = 0,
24 - .received = { NAN, NAN },
25 - .sent = { NAN, NAN },
26 - };
21 + .received = {NAN, NAN},
22 + .sent = {NAN, NAN},
23 + };
24 +
25 + cg->cgroup_netdev_link =
26 + dictionary_set_and_acquire_item(cgroup_netdev_link_dict, cg->id, &t, sizeof(struct cgroup_netdev_link));
27 + }
28
28 - cg->cgroup_netdev_link = dictionary_set_and_acquire_item(cgroup_netdev_link_dict, cg->id, &t, sizeof(struct cgroup_netdev_link));
29 return dictionary_acquired_item_dup(cgroup_netdev_link_dict, cg->cgroup_netdev_link);
30 }
31
@@ -34,6 +34,7 @@ void cgroup_netdev_delete(struct cgroup *cg) {
34 dictionary_acquired_item_release(cgroup_netdev_link_dict, cg->cgroup_netdev_link);
35 dictionary_del(cgroup_netdev_link_dict, cg->id);
36 dictionary_garbage_collect(cgroup_netdev_link_dict);
37 + cg->cgroup_netdev_link = NULL;
38 }
39 }
40
libnetdata/log/log.c
+10 -1
@@ -2305,7 +2305,16 @@ void netdata_logger_fatal( const char *file, const char *function, const unsigne
2305 char action_data[70+1];
2306 snprintfz(action_data, 70, "%04lu@%-10.10s:%-15.15s/%d", line, file, function, saved_errno);
2307
2308 - const char *thread_tag = thread_log_fields[NDF_THREAD_TAG].entry.txt;
2308 + char os_threadname[NETDATA_THREAD_NAME_MAX + 1];
2309 + const char *thread_tag = netdata_thread_tag();
2310 + if(!netdata_thread_tag_exists()) {
2311 + if (!netdata_thread_tag_exists()) {
2312 + os_thread_get_current_name_np(os_threadname);
2313 + if ('\0' != os_threadname[0])
2314 + /* If it is not an empty string replace "MAIN" thread_tag */
2315 + thread_tag = os_threadname;
2316 + }
2317 + }
2318 if(!thread_tag)
2319 thread_tag = "UNKNOWN";
2320