diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2023-02-08 20:53:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-08 20:53:43 +0200 |
commit | 7f0486761408f5eae806671434751fae6de358dd (patch) | |
tree | 1f9efaf091f01716e54c104566bf1557b4704181 /collectors | |
parent | 870ce8516b1272b03712d7417d444b10045cd105 (diff) |
Fix random crash on agent shutdown (#14470)
Check MMAP failure. If fail to create semaphore, clear the shm_cgroup_ebpf.header to avoid crash during shutdown on thread cleanup
Diffstat (limited to 'collectors')
-rw-r--r-- | collectors/cgroups.plugin/sys_fs_cgroup.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c index 66db0b7281..e63e042d09 100644 --- a/collectors/cgroups.plugin/sys_fs_cgroup.c +++ b/collectors/cgroups.plugin/sys_fs_cgroup.c @@ -589,7 +589,8 @@ void netdata_cgroup_ebpf_initialize_shm() PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd_cgroup_ebpf, 0); - if (!shm_cgroup_ebpf.header) { + if (unlikely(MAP_FAILED == shm_cgroup_ebpf.header)) { + shm_cgroup_ebpf.header = NULL; collector_error("Cannot map shared memory used between cgroup and eBPF, integration won't happen"); goto end_init_shm; } @@ -606,6 +607,7 @@ void netdata_cgroup_ebpf_initialize_shm() collector_error("Cannot create semaphore, integration between eBPF and cgroup won't happen"); munmap(shm_cgroup_ebpf.header, length); + shm_cgroup_ebpf.header = NULL; end_init_shm: close(shm_fd_cgroup_ebpf); |