-
Notifications
You must be signed in to change notification settings - Fork 109
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
Subscriptions and shared memory produce UB when moved #33
Comments
I'm not 100% sure whether I understand the example correctly. For me 'count>0' evaluates to 'false' (in the first run). Hence, at first sight the led never turning on makes sense to me, as there is no callback registered. |
Moreover, you need an event to wake you from a yield. I don't know if the body of |
Hmm... I am pretty sure there is some sort of problem but maybe not in the yield function. @brghena Maybe you could have a look at https://github.com/torfmaster/libtock-rs/blob/feature/unsafe-cleanup/src/console.rs? When I
The value for By the way, |
@brghena Before you waste your time: I am pretty sure that the subscriptions are broken. Let me check that first... |
Okay, I found the bug. It's not in I am trying to solve that problem by making |
I believe the problem is that in Instead, the callback value needs to be (logically) stored away somewhere, e.g., by calling |
The problem is not that a Instead, the problem is that the current implementation allows The correct way would be to consume Of course, this has an impact on the libtock API (which I consider far from stable anyway). The new API could look like this: let callback = ButtonsCallback::new(|a, b| {
/* Callback code here */
});
let buttons = Buttons::with_callback(&mut callback); Being a bit more verbose, unfortunately, a change of this kind is unavoidable IMO. My feeling is that we are very close to having a safe subscription/allow API for |
- Make syscalls::subscribe consume &mut CB instead of CB
- Make syscalls::subscribe consume &mut CB instead of CB
From my understanding, the following code should turn on an LED but it doesn't:
There are no kernel panics and the
yieldk
loop seems to be inactive...Any idea what could be the problem? Did I make a mistake?
The text was updated successfully, but these errors were encountered: