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

shutdown function should be marked unsafe #6195

Open
DavidThien opened this issue Dec 5, 2023 · 0 comments
Open

shutdown function should be marked unsafe #6195

DavidThien opened this issue Dec 5, 2023 · 0 comments
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug.

Comments

@DavidThien
Copy link

DavidThien commented Dec 5, 2023

Version
>= 1.8.1

Platform
Linux system76-pc 6.2.6-76060206-generic #202303130630~1689015125~22.04~ab2190e~dev-Ubuntu SMP PREEMPT_DY x86_64 x86_64 x86_64 GNU/Linux (any)

Description
The shutdown function not properly marked unsafe.

I've been looking at some past bugs in tokio, and came across #3929 where abort changed from calling shutdown to remote_abort.

pub fn abort(&self) {
if let Some(raw) = self.raw {
raw.remote_abort();
}
}

This change was made because shutdown isn't safe to call in some contexts, or it might cause the original issue. It seems that the current shutdown function should be marked unsafe, because the code hasn't changed, and you can still call it in a way that causes the program to go wrong. Rust conventions seem to indicate this should be marked unsafe.

pub(super) fn shutdown(self) {
let vtable = self.header().vtable;
unsafe { (vtable.shutdown)(self.ptr) }
}

This isn't a safety issue currently, but could cause one in the future.

@DavidThien DavidThien added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant