Ai
1 Star 0 Fork 18

阿翔与山海经/gala-gopher

forked from src-openEuler/gala-gopher 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fix-stackprobe-memory-allocation-and-deallocation-er.patch 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
陈臻 提交于 2023-01-14 06:21 +08:00 . sync bugfix patches from openeuler/gala-gopher
From 01f2d382131f26ca81b0997532d0b73515ca33c7 Mon Sep 17 00:00:00 2001
From: wo_cow <niuqianqian@huawei.com>
Date: Wed, 14 Dec 2022 16:32:13 +0800
Subject: [PATCH] fix stackprobe memory allocation and deallocation errors.
---
.../extends/ebpf.probe/src/stackprobe/stackprobe.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c b/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c
index da09094..fa37a72 100644
--- a/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c
+++ b/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c
@@ -105,7 +105,7 @@ typedef struct {
struct bpf_link_hash_value {
enum pid_state_t pid_state;
char elf_path[MAX_PATH_LEN];
- struct bpf_link *bpf_links[32];
+ struct bpf_link *bpf_links[32]; // 32 cover num of probes in memleak.bpf.c
};
struct bpf_link_hash_t {
@@ -314,7 +314,7 @@ static struct raw_stack_trace_s *create_raw_stack_trace(struct stack_trace_s *st
size_t stack_size = st->cpus_num * PERCPU_SAMPLE_COUNT;
size_t mem_size = sizeof(struct raw_stack_trace_s);
- mem_size += (stack_size * sizeof(struct stack_id_s));
+ mem_size += (stack_size * sizeof(struct raw_trace_s));
raw_stack_trace = (struct raw_stack_trace_s *)malloc(mem_size);
if (!raw_stack_trace) {
@@ -747,7 +747,6 @@ static void destroy_svg_stack_trace(struct svg_stack_trace_s **ptr_svg_st)
static void destroy_stack_trace(struct stack_trace_s **ptr_st)
{
- // TODO:destroy_svg_stack_trace?
struct stack_trace_s *st = *ptr_st;
*ptr_st = NULL;
if (!st) {
@@ -761,6 +760,13 @@ static void destroy_stack_trace(struct stack_trace_s **ptr_st)
}
}
+ for (int i = 0; i < STACK_SVG_MAX; i++) {
+ if (st->svg_stack_traces[i] == NULL) {
+ continue;
+ }
+ destroy_svg_stack_trace(&st->svg_stack_traces[i]);
+ }
+
if (st->ksymbs) {
destroy_ksymbs_tbl(st->ksymbs);
(void)free(st->ksymbs);
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/a-xiang-and-shanhaijing/gala-gopher.git
git@gitee.com:a-xiang-and-shanhaijing/gala-gopher.git
a-xiang-and-shanhaijing
gala-gopher
gala-gopher
master

搜索帮助