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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe blocks review #64

Closed
pinkforest opened this issue Sep 25, 2022 · 9 comments
Closed

Unsafe blocks review #64

pinkforest opened this issue Sep 25, 2022 · 9 comments
Labels
question Further information is requested

Comments

@pinkforest
Copy link

pinkforest commented Sep 25, 2022

Hi considering this crate is getting popular 馃コ congrats great work ~80k a day from less than a month :)

Just an idea as this crate is becoming very important in the ecosystem ..

or FWIW considering I am deeply interested about unsafe across the whole Rust 馃 ecosystem I wanted to chime in :)

Have you considered / or had anyone to vet these unsafe blocks in this crate properly through externally like some neutral 3rd party not deep in the project / associated crates ? I didn't see anything in crev or safety-dance.

You could also just hold back merging anything that touches any unsafe {} and put a label like Unsafe-Proposed and let it sit for a week unless it is critical urgent change - so the community has the chance to chime in - that's what I do in advisory-db to radiate my intent especially on controversial advisories that are not necessarily as time critical -

By radiating intent everyone feels having a chance to say something that leads less to haphazard changes people feeling included

Also I find easiest raising issues first and then doing a PR when people either agree with me or we refine the idea / issue first

@astraw
Copy link
Member

astraw commented Sep 26, 2022

Thanks for the thoughts and pointers.

I would be happy for someone to vet the unsafe blocks. How would you suggest we facilitate that?

The Unsafe-Proposed label also seems like a good idea.

We have become so "low level" that in some cases we cannot rely on higher level libraries, for example #50 and #61.

@pinkforest
Copy link
Author

pinkforest commented Sep 27, 2022

Great - We can organise this via safety-dance - I've added issue at rust-secure-code/safety-dance#79

@lopopolo
Copy link
Collaborator

One bit that I've been thinking about is that the windows and macOS internals are implemented by big unsafe fn. I don't think that's quite right. The functions are not unsafe to call (there's no invariants callers must uphold).

Instead, the functions seem to be declared as unsafe fn to avoid having to use and document unsafe blocks in their internals.

@lopopolo
Copy link
Collaborator

I would like to find find a way to fail CI when the following lints fire:

  • unsafe_op_in_unsafe_fn
  • clippy::undocumented_unsafe_blocks

@pinkforest
Copy link
Author

pinkforest commented Sep 27, 2022

For clippy you would have to add it into github action - that undocumented lint was stabilised I think

unsafe_op I am not sure it was stabilised so might need +nightly for cargo clippy

You can put thhem into lib.rs as #[deny(..)] if they were not default.. I think undocumented was warn by default

You could gate any nightly-needed features so you don't suddenly require nightly for complication - e.g. gate them via nightly feature and then use that feature in CI

@lopopolo
Copy link
Collaborator

@pinkforest ahh I meant getting the code changed so the lints would pass.

For flipping the lints on, my preference would be to set them as warnings either in lib.rs or on the CLI invocations of clippy and cargo check in CI with RUSTFLAGS="-D warnings" in the env for all GitHub Actions jobs.

@Kijewski
Copy link
Collaborator

Kijewski commented Sep 27, 2022

Instead, the functions seem to be declared as unsafe fn to avoid having to use and document unsafe blocks in their internals.

As the person who wrote the functions: You're right, I did not want to wrap every other line in unsafe.

@lopopolo lopopolo added the question Further information is requested label Sep 30, 2022
@pinkforest
Copy link
Author

Closing as question answered - thanks!

@astraw
Copy link
Member

astraw commented Nov 22, 2022

@pinkforest many thanks, I think this really improved the crate! We will endeavor to keep up the high standard and please feel free to remind us of this goal in the future. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants