-
Notifications
You must be signed in to change notification settings - Fork 4
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
Crate does not compile with latest beta
#13
Comments
I wonder if that's true? I thought the Rust compiler wouldn't retroactively break code in this way. It's still an issue if this doesn't work in A lot of the errors are coming from |
It seems like this error will be switched back to allow-by-default, at least temporarily: rust-lang/rust#113422 If this is brought to stable, it will break |
Fair enough. I searched for relevant discussions in Hopefully it will be switched back. I, too, have a bunch of code in my AfterEffects API Rust binding that will cease to work if it isn't. |
Rust compiler contributors here and author of the Saw this issue as linked to rust-lang/rust#113422 and wanted to clear some questions you were wondering.
The Rust compiler promises to never break compiling sound code, that means the code must not violate any invariants. This is automatically the case for safe code, for unsafe code it's up to the developer to respect those invariants (otherwise safe code would be as unsafe as unsafe code). These invariants include but are not limited to (Unsafe Code Guidelines to see more) aliasing, which as the lint is says, the code is pure violation of it. That's why If this hasn't any caused any miscompilation yet, I wouldn't be surprised if a future version of the compiler miscompiled the code around it, as
That a shame that
Sorry, rust-lang/rust#112431 just landed are re-enabled the lint with an improved diagnostics under the |
Looks like my fears were a tad premature so far for the crate I mentioned. I am not doing anything like |
@Urgau That makes sense, thanks for dropping in! Indeed, Do you have recommendations for how to go from a mutable pointer to a mutable reference? Do you recommend replacing all pointers with |
Except that the mutable reference was created from a read-only pointer (the shared reference). Making the creation of the mutable reference immediately UB, no matter if it's used or not. See this example with Miri on playground.
Well I'm not familiar with this code, but from a quick look I'm wondering why the rusty_spine/src/c_interface.rs Lines 612 to 621 in abf7844
... which takes a mutable reference, as far as I can tell. As for a general recommendation, I cannot really give one as I'm not that prolifically with unsafe code, but I would say stick with raw pointers when you have a doubt, if you can satisfy the all the aliasing requirements use |
Thanks for your help @Urgau! This problem is easily solved by simply adding the necessary The
needs to become:
|
I released |
❤️ Thanks, that makes it all worth while.
Well it's no really that is "improves" stuff but that it temporarily doesn't lint on things that requires an aliasing/memory model, ie Stack Borrow or Tree Borrow, since neither of them are official.
I should just note that this is still UB per Miri since Stack Borrow consider intermediate cast as relevant and casting
I would highly recommend just removing those unnecessary and potentially future UB cast. - *(&mut (*bone).b as *const c_float as *mut c_float) *= s;
+ *(&mut (*bone).b as *mut c_float) *= s; EDIT: The |
Thanks again @Urgau. The c2rust code is probably a landmine of UB, unfortunately. |
This has been fixed with the release of rustc beta 1.73 and rusty_spine 0.6.1, and I've made UB fixes that should hopefully appease future rust lints. There is some work to be done to automate these UB fixes when generating the rust code from spine-c. The UB actually originates from non-performance related UB in the spine-c runtimes (specifically, const casts). It might warrant a PR for spine-c, but since it doesn't appear to be an issue in practice, it's hard to justify the change. |
Why not just open a ticket and link this issue to create awareness with the |
I plan to, at some point. I don't really know what to say. In all my experience writing C, this is a purely theoretical problem. If someone has a more compelling argument, it would be helpful. |
Since this is an issue when building with the
beta
channel already it will forseeably become a bug when trying to build this crate withstable
. Basically, there are dozens of those:The text was updated successfully, but these errors were encountered: