-
Notifications
You must be signed in to change notification settings - Fork 149
Program::attach_uprobe_with_opts()
fails when building with --release
#447
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
Comments
libbpf-rs's initialization of libbpf's opts structs doesn't seem to do memset(0), which libbpf's LIBBPF_OPTS() macro does (see). Unfortunately only since C23 it will be specified that C compiler has to zero-initialize paddings, so until then we have to keep making weird hacks like the one in LIBBPF_OPTS(). I actually don't know what is Rust's stance on this. |
I haven't found an authoritative answer for
It's not entirely clear to me whether |
What I am confused about currently is why we hit this issue to begin with: bindgen makes padding bytes explicit (e.g., |
And the answer is: --- libbpf-rs/src/program.rs
+++ libbpf-rs/src/program.rs
@@ -545,7 +545,7 @@ impl Program {
let func_name = util::str_to_cstring(&func_name)?;
let opts = libbpf_sys::bpf_uprobe_opts {
- sz: mem::size_of::<Self>() as u64,
+ sz: mem::size_of::<libbpf_sys::bpf_uprobe_opts>() as _,
ref_ctr_offset: ref_ctr_offset as libbpf_sys::size_t,
bpf_cookie: cookie,
retprobe, |
This change fixes the sz member initialization of bpf_uprobe_opts objects that we use in the uprobe attach code. The previously incorrect size could lead to libbpf failing the attachment on optimized builds, where the size of Program objects was different to dev ones. Fixes: #447 Signed-off-by: Daniel Müller <[email protected]>
Run tests on release builds to catch issues such as #447 early on. Signed-off-by: Daniel Müller <[email protected]>
I've ran into an issue while deploying binary build with
cargo build --release
that attaches some uprobes to C++ functions. Locally,cargo build
without--release
, it works fine. To confirm the issue I've changed the libbpf CI to run with--release
in 0xB10C@11b11f7.From this run:
I'm seeing the same issue with
libbpf: bpf_uprobe_opts has non-zero extra bytes
in my release builds. At the moment, I don't have any clue what could be causing this, yet.The text was updated successfully, but these errors were encountered: