Skip to content
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

runtime: fix Stacked Borrows violation in LocalOwnedTasks #5099

Merged
merged 2 commits into from Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion tokio/src/runtime/task/list.rs
Expand Up @@ -240,7 +240,7 @@ impl<S: 'static> LocalOwnedTasks<S> {
self.with_inner(|inner|
// safety: We just checked that the provided task is not in some
// other linked list.
unsafe { inner.list.remove(task.header().into()) })
unsafe { inner.list.remove(task.header_ptr()) })
}

/// Asserts that the given task is owned by this LocalOwnedTasks and convert
Expand Down
19 changes: 19 additions & 0 deletions tokio/src/task/local.rs
Expand Up @@ -921,3 +921,22 @@ impl task::Schedule for Arc<Shared> {
}
}
}

#[cfg(test)]
mod tests {
use super::*;
#[test]
fn local_current_thread_scheduler() {
let f = async {
LocalSet::new()
.run_until(async {
spawn_local(async {}).await.unwrap();
})
.await;
};
crate::runtime::Builder::new_current_thread()
.build()
.expect("rt")
.block_on(f)
}
}