Skip to content

Panic when export C struct to skel #1155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3Xpl0it3r opened this issue Apr 21, 2025 · 2 comments
Closed

Panic when export C struct to skel #1155

3Xpl0it3r opened this issue Apr 21, 2025 · 2 comments

Comments

@3Xpl0it3r
Copy link

3Xpl0it3r commented Apr 21, 2025

After I export c struct to skel, prog panic when load bpf code
panic message:
thread 'main' panicked at /Users/l0calh0st/Git/Rust/netdig/src/bpf/netdig.skel.rs:129:26: BPF mapbssmmap pointer is NULL note: run withRUST_BACKTRACE=1environment variable to display a backtrace
example code as blow

`struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
__uint(key_size, sizeof(u32));
__uint(value_size, sizeof(u32));
__uint(max_entries, 1024);
} events SEC(".maps");

struct skb_tuple_t {
u16 sport;
};

struct skb_tuple_t _event = {}; // This code cause panic

SEC("kprobe/ip_rcv") // SEC("kprobe/ip_rcv_core")
int kprobe_ip_rcv_core(struct pt_regs *ctx) {
u16 pid = 10;
struct skb_tuple_t tupple = {};
tupple.sport = pid;
bpf_perf_event_output(ctx, &events, 0, &tupple, sizeof(tupple));
return BPF_OK;
}

char _license[] SEC("license") = "GPL";
`

osversion: Linux lima-ubuntu20 5.4.0-212-generic 2025 x86_64 x86_64 x86_64 GNU/Linux

libbpf-rs version: 0.24.8
libbpf-cargo version: master

@olcarver
Copy link

Looks like this is the same issue I experienced here #1151. If you need a work around now, you can downgrade to an older version. Can confirm that 0.21.x works for older kernels.

@d-e-s-o
Copy link
Collaborator

d-e-s-o commented Apr 30, 2025

Closing a duplicate of #1151

@d-e-s-o d-e-s-o closed this as completed Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants