Closed terhechte closed 1 year ago
So I did some debugging. What happens is that the task is removed from the scheduler tasks
once it finishes in wait.rs:32
:
// If the task completes...
if task.task.borrow_mut().as_mut().poll(&mut cx).is_ready() {
// Remove it from the scope so we dont try to double drop it when the scope dropes
self.scopes[task.scope.0].spawned_tasks.remove(&id);
// Remove it from the scheduler
tasks.remove(id.0);
}
It looks like restarting a task tries to remove the old task, which fails if the task already finished prior to that in task.rs:56
:
/// This does nto abort the task, so you'll want to wrap it in an aborthandle if that's important to you
pub fn remove(&self, id: TaskId) {
self.tasks.borrow_mut().remove(id.0);
}
I have a local fix that only removes the task if it still exists. Not sure if that is the correct solution though.
This seems like the right approach! implemented in #718
👍 :)
Problem
I have a super simple example that panics on latest master when tapping the button that restarts the future.
Steps To Reproduce
Steps to reproduce the behavior:
Expected behavior
No Panic
Logs
It generates multiple panics, here's the console output:
Environment: