-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
coroutine_pause.rs test broken on head #693
Comments
The error comes from this impl Drop for GlPipelineGuarded {
fn drop(&mut self) {
get_context().gl.delete_pipeline(self.0);
}
} The mutable static A Since When starting the first test, At the end of the first test, this object will not be dropped and remain the same when the second test begins. The second test will then try to reassign a new Now, I see these options:
|
The error changed with the release of the latest miniquad version: it panics now instead of causing visible UB:
|
This needs to be fixed within miniquad as even this minimized example of two macroquad tests without content panics: pub mod test {
pub static mut MUTEX: Option<std::sync::Mutex<()>> = None;
pub static ONCE: std::sync::Once = std::sync::Once::new();
}
struct Stage {}
impl miniquad::EventHandler for Stage {
fn update(&mut self) {}
fn draw(&mut self) {
miniquad::window::quit();
}
}
pub fn new_window() {
miniquad::start(miniquad::conf::Conf::default(), || Box::new(Stage {}));
}
#[test]
fn x() {
let _lock = unsafe {
test::ONCE.call_once(|| {
test::MUTEX = Some(std::sync::Mutex::new(()));
});
test::MUTEX.as_mut().unwrap().lock()
};
new_window();
}
#[test]
fn y() {
let _lock = unsafe {
test::ONCE.call_once(|| {
test::MUTEX = Some(std::sync::Mutex::new(()));
});
test::MUTEX.as_mut().unwrap().lock()
};
new_window();
} |
This seems hard to fix: static NATIVE_DISPLAY: OnceLock<Mutex<native::NativeDisplayData>> = OnceLock::new();
fn set_display(display: native::NativeDisplayData) {
NATIVE_DISPLAY
.set(Mutex::new(display))
.unwrap_or_else(|_| panic!("NATIVE_DISPLAY already set"));
}
fn native_display() -> &'static Mutex<native::NativeDisplayData> {
NATIVE_DISPLAY
.get()
.expect("Backend has not initialized NATIVE_DISPLAY yet.") //|| Mutex::new(Default::default()))
} It would be necessary to drop this value at the end of each test, which would require replacing |
When running
cargo test
in my fork, I see the following error:The text was updated successfully, but these errors were encountered: