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

LocalIo is unsafe and should not be. #11053

Closed
alexcrichton opened this issue Dec 18, 2013 · 1 comment
Closed

LocalIo is unsafe and should not be. #11053

alexcrichton opened this issue Dec 18, 2013 · 1 comment
Assignees
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows

Comments

@alexcrichton
Copy link
Member

The current implementation of LocalIo involves unsafe borrowing which doesn't transfer ownership of the IoFactory. This unsafe code allows for mutably aliasing the IoFactory multiple times on the stack (leading to memory unsafety).

Fixing this would involve dancing around transferring ownership of the IoFactory between the calls that it makes. My initial idea was for LocalIo to take ownership and give out &mut loans to it, but this is insufficient because when a green task context switches the scheduler must again have ownership of the IoFactory.

My best idea for doing this right now is to change all methods on IoFactory to take ~self and then right before the M:N methods block they would transfer ownership back to the scheduler. All the 1:1 methods would basically immediately return ownership of the factory back to the local Task.

@steveklabnik
Copy link
Member

All of this is irrelevant with libgreen gone.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 14, 2023
Use `cargo build --tests` in CI

I noticed that we run a `cargo build` but end up downloading/building a bunch of deps after that for tests in CI

https://github.com/rust-lang/rust-clippy/actions/runs/5426673277/jobs/9869019973#step:6:12
https://github.com/rust-lang/rust-clippy/actions/runs/5426673277/jobs/9869019973#step:7:11

This builds the tests in the build step too, it may speed up runs by downloading/building more in parallel

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows
Projects
None yet
Development

No branches or pull requests

2 participants