yunwei37 / nginx-lua-ebpf-toolkit

profile and tracking tools for lua and nginx using eBPF
https://github.com/apache/apisix-profiler
57 stars 12 forks source link

启动报错 #1

Closed cloudfreexiao closed 3 months ago

cloudfreexiao commented 2 years ago
 系统:ubuntu 22.04 内核: Linux Parallels-Virtual-Platform 5.15.0-48-generic
运行报错日志:

regs=4 stack=0 before 335: (b7) r2 = 8
; if (frame_isvarg(frame))
338: (79) r7 = *(u64 *)(r10 -8)
BPF program is too large. Processed 1000001 insn
processed 1000001 insns (limit 1000000) max_states_per_insn 22 total_states 25177 peak_states 612 mark_read 14
-- END PROG LOAD LOG --
libbpf: prog 'do_perf_event': failed to load: -7
libbpf: failed to load object 'profile_bpf'
libbpf: failed to load BPF skeleton 'profile_bpf': -7
failed to load BPF programs
=================================================================
==24220==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x7ffc47ff92c0 in thread T0
    #0 0x7f0bdb8a3517 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127
    #1 0x55652ad23e00 in main /nginx-lua-ebpf-toolkit/bpftools/profile_nginx_lua/profile.c:888
    #2 0x7f0bdb283d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0x7f0bdb283e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #4 0x55652ad1e4a4 in _start (/ebpf/nginx-lua-ebpf-toolkit/bpftools/profile_nginx_lua/profile+0xb4a4)

Address 0x7ffc47ff92c0 is located in stack of thread T0 at offset 1040 in frame
    #0 0x55652ad23162 in main nginx-lua-ebpf-toolkit/bpftools/profile_nginx_lua/profile.c:728
yunwei37 commented 2 years ago

也许可以修改一下这里的这个 15,把它调小:

https://github.com/yunwei37/nginx-lua-ebpf-toolkit/blob/b5de03a830c66401402604bda38b29cb8069da50/bpftools/profile_nginx_lua/profile.bpf.c#L130

它应该被作为一个命令行参数传入 ebpf 程序,而不是作为一个常量。在我的机器上这个值没有问题,但是可能由于内核版本不同会有一些偏差,导致最大指令数超过上限。

或者之后也许可以用 bpf iter 之类的方式解决?

cloudfreexiao commented 2 years ago

更新代码报错来着~~~

profile.bpf.c:170:15: error: variable has incomplete type 'struct key_t'
        struct key_t key = {};
                     ^
profile.bpf.c:23:21: note: forward declaration of 'struct key_t'
        __type(key, struct key_t);
                           ^
1 error generated.
make: *** [Makefile:66: .output/profile.bpf.o] Error 1
cloudfreexiao commented 2 years ago

@yunwei37 有个问题很奇怪 以下这些事件都不会触发呢?查了很久都没找到原因 和我系统,内核版本有关系吗?

SEC("perf_event")

SEC("uprobe/handle_entry_lua_cancel") 

SEC("uprobe/handle_entry_lua")
yunwei37 commented 3 months ago

是不是没有 debug 的信息,或者debug 的信息和版本不匹配?