We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have a serious issue I cannot explain. My guess is that copyless creates some sort of memory issue when called with static functions.
assume the following traits:
pub struct Runnable { runnable_box: Box<RunnableBox + Send> } impl Runnable { pub fn run(self) { self.runnable_box.run(); } } trait RunnableBox { fn run(self: Box<Self>); } impl<F: FnOnce()> RunnableBox for F { fn run(self: Box<F>) { (*self)() } }
And these two constructors, one using Box::new, the other using Box::alloc().init
impl Runnable { pub fn new_box<F>(func: F) -> Runnable where F: FnOnce() + Send + 'static { Runnable { runnable_box: Box::new(func) } } #[allow(dead_code)] pub fn new_copyless<F>(func: F) -> Runnable where F: FnOnce() + Send + 'static { Runnable { runnable_box: Box::alloc().init(func) } } }
Creating a static Runnable seems to create some sort of memory overwrite I cannot exactly pin down:
Runnable::new_box(move || { println!("scheduled task 1"); }); // Works Runnable::new_copyless(move || { println!("scheduled task 1"); }) // Error let now = Instant::now(); Runnable::new_copyless(move || { println!("scheduled task 1 {:?}", now); }) // Works
I have attached a testcase that fails on macos and on linux using Rust 1.33 stable and rustc 1.35.0-nightly (0576ac109 2019-03-24).
copyless.tar.gz
The text was updated successfully, but these errors were encountered:
This PR seems to fix the issue: #8
Sorry, something went wrong.
Closing this issue since #8 has been merged. Will investigate and reopen if this issue pops up again. Thank you @kvark
No branches or pull requests
I have a serious issue I cannot explain. My guess is that copyless creates some sort of memory issue when called with static functions.
assume the following traits:
And these two constructors, one using Box::new, the other using Box::alloc().init
Creating a static Runnable seems to create some sort of memory overwrite I cannot exactly pin down:
I have attached a testcase that fails on macos and on linux using Rust 1.33 stable and rustc 1.35.0-nightly (0576ac109 2019-03-24).
copyless.tar.gz
The text was updated successfully, but these errors were encountered: