-
Notifications
You must be signed in to change notification settings - Fork 124
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
it is undefined behavior to use this value
error on latest nightly compiler
#698
Comments
I've bisected the nightly releases, and found the change which causes this error (tested on master of this repo): searched nightlies: from nightly-2024-02-09 to nightly-2024-02-11 bisected with cargo-bisect-rustc v0.6.8Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc |
Looks like rustc is not happy about a ref to a mutable static here: pub static WL_CALLBACK_INTERFACE: wayland_backend::protocol::Interface =
wayland_backend::protocol::Interface {
name: "wl_callback",
version: 1u32,
requests: &[],
events: &[wayland_backend::protocol::MessageDesc {
name: "done",
signature: &[wayland_backend::protocol::ArgumentType::Uint],
since: 1u32,
is_destructor: true,
child_interface: None,
arg_interfaces: &[],
}],
// This causes the error
c_ptr: Some(unsafe { &wl_callback_interface }),
};
pub static mut wl_callback_interface: wayland_backend::protocol::wl_interface =
wayland_backend::protocol::wl_interface {
name: b"wl_callback\x00" as *const u8 as *const std::os::raw::c_char,
version: 1,
request_count: 0,
requests: NULLPTR as *const wayland_backend::protocol::wl_message,
event_count: 1,
events: unsafe { &wl_callback_events as *const _ },
}; Not sure why this static needs to be mutable yet. EDIT: Nevermind it got even worse, now I get:
Nightly is fun. |
The fact that the error is |
The issue you pointed @PolyMeilex seems to have been reported already as rust-lang/rust#120949 and apparently has a coming fix rust-lang/rust#120960 . The reason we have |
What's happening is that the checks for whether The cycle error should be fixed soon, but this UB check is remaining. Though it is strange that it says "in |
@RalfJung I think the problem with the code extract is that it was missing a level of indirection. This example does reproduce the issue: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=b12b75e175cc0fc7ca186ed0e2ec869f Now, as I wrote earlier, it is indeed entirely possible that the use of |
Ah! Yes there we have
Interesting. I'm not aware of how adding a If |
It appears this issue also happens with interior mutability with types like |
Though CI passing there will require a nightly that fixes the "cycle detected when const-evaluating " issue, I guess. |
Okay, good to know. :) The fix landed, so a nightly with the fix should be released in a few hours. |
This seems to be fixed as of |
Yeah, I think we can close this now. #700 should be a bit better of a way to do things, but not make any difference in behavior baring compiler bugs. |
Building on the latest nightly compiler (rustc 1.78.0-nightly (6cc484351 2024-02-10)) causes the following error:
The text was updated successfully, but these errors were encountered: