-
Notifications
You must be signed in to change notification settings - Fork 142
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
NonNull<bpf_object> cannot be shared between threads safely #1027
Comments
Can you provide the full reproducible example? |
Hi @d-e-s-o, I'm still trying to wrap my head around completely. It has to do with the modifications on the Bpf structure itself due to the addition of the storage in it because of the 0.24 requirements. I just tested the following back with 0.23.3:
This gives the same error. Just as I expected. So it's not the NonNull itself. That has always been However, my own code before was different, since I didn't have to keep a separate Previously I had:
So this must not have had any NonNull pointers in it and thus was
and thus the error. |
Generated code in 0.23.3:
Generated code in 0.24.8:
So in both cases |
So, if my understanding is correct, it is the "bundling" of the |
So implement |
Thanks for that. It worked, but with caveats.
I tried that before but I also got this clippy (nursery) warning message:
This warning made sense to me and I thought that I should not continue with this approach, because I am indeed wrapping a Is it really safe to do so though in all cases? I didn't read in full the previous (0.23.3) implementation of the skeleton storage, but if it was already part of the skeleton structure itself and the skeleton itself was marked as Thanks again Daniel |
There was no concept of "storage" per se in earlier versions from what I recall, as it wasn't necessary. But my understanding is that it is safe to implement both My guess is that Clippy warns because |
And actually when we do that I guess you wouldn't need the |
Right. Let me take a look here and pay back a tiny bit with a PR! Reopening this now. |
Sounds good. FWIW, I was just reminded of this prior discussion/analysis on the matter: #245 (comment) That being said, by now |
Submitted a PR after testing against my code (after I removed my own implementations). |
PR has been updated with implementations on both |
Hi @danielocfb,
As a follow up from #1017, I wanted to open this issue separately. To summarize here again.
I've been using
0.23.3
and I am currently in the processing of trying to upgrade to0.24.8
(latest stable as of now).I have my own structure which then I share across multiple threads like this:
The structure, with the latest modification of embedding the storage in it looks like this now:
Now I get the following compilation error:
Now, I am not entirely sure where the issue is rooted in. The OpenObject currently (https://github.com/libbpf/libbpf-rs/blob/v0.24.8/libbpf-rs/src/object.rs#L222) is:
NonNull
itself has the following:So that makes sense to be non-Sync. However, what I don't know yet is what changed exactly. Previously, in 0.23.3, OpenObject was (https://github.com/libbpf/libbpf-rs/blob/v0.23.3/libbpf-rs/src/object.rs#L153):
So again, it contains
ptr: NonNull<libbpf_sys::bpf_object>
which should make it!Sync
as well. Then how was I able to use it previously?I am not a Rust expert and I'm sure I am missing something here. I'll continue looking into it, but any help is appreciated.
Thanks
The text was updated successfully, but these errors were encountered: