-
Notifications
You must be signed in to change notification settings - Fork 436
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
binder: fix use-before-init of spinlock #366
Conversation
This causes `BUG: spinlock bad magic`. Signed-off-by: Gary Guo <[email protected]>
Review of
|
So, this looks correct to me.... but I'd love to think about how we could solve this better at the API level, to catch this at compile time. |
Well, I guess #290 is related... |
So is #290 (comment) :) Why am I worried about this whole Pinning + unsafe business? This is the second instance that surfaces this month in our own code. If we are likely to make mistakes of this kind, what chance do driver writers less familiar with Rust have? Will this be an improvement to C? (This by no means implies criticism of @wedsonaf whose judgement and code I respect greatly) |
So is #145 (comment) :)
Before Sven and Gary joined us, we had a discussion about this in one of the public meetings when I started creating these abstractions that required pinning. Broadly speaking we had two options: do what Rust does internally in its std library, which is to ignore the problem, and just assume that things behind As I said in some other comment, my intent is try to talk to the language folks and improve this in the language (as I started to do in the comment above). Having cases like these I think strengthen our case that we need better language support for this.
Thanks Sven, that's very kind. This is one of the reasons why we need languages like Rust, they can help us catch bugs. (It didn't this time, but it should.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, thanks @nbdd0121 for spotting and fixing this!
Does the benchmark work for you after this fix?
Sadly still not. |
💯 I wonder if we can make an argument for allowing driver writers to choose which
Once the language support is up to scratch, we may drop support for |
Can't we just add a new method (or macro due to lockdep) that returns |
We could. Two possible issues here:
Edit: in the client drivers, we frequently see |
Which arch are you testing this on? |
I am testing this on 64-bit RISC-V (RV64GC). |
In Rust, whether something needs pinning or not is not a property of type; all type |
Not if |
In that case you should use To be fair, the concept that everything is movable is not unique to Rust; it applies to C as well. E.g. you can write |
This causes
BUG: spinlock bad magic
.