Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upReduce the use of `unsafe` in the ecosystem #19
Comments
Shnatsel
added
the
2019 goal
label
Jan 14, 2019
This comment has been minimized.
This comment has been minimized.
DevQps
commented
Mar 15, 2019
|
I think this is a nice goal! I guess it would be nice if we had some way to validate our results at the end of this year. I saw Cargo Geiger being mentioned somewhere and I think it is a very nice tool to use to verify our results. Maybe we could automatize running Cargo Geiger on the top X most downloaded crates on crates.io and store the results? This way we could see by how much unsafe statements would be reduced or increased. Personally I also think that if we focus on creating good (safe) abstractions of unsafe operations or provide safe alternatives that are just as performant the amount of unsafe usage will automatically go down. If we could succeed in creating such things, we would only have to point them out to crate authors. |
This comment has been minimized.
This comment has been minimized.
|
I don't have time to work on this right now, but here it is in case somebody else does: I recently came across some code in the image crate which uses I wonder if it would be possible to create a utility that allows doing this safely. I'm not sure exactly how it would work, but the idea would be to architect it so that you only modify the length once, and then allow read/write access to the initialized part of the vector while only allowing an |
Shnatsel commentedJan 14, 2019
Many widely used libraries use unsafe code where it's not strictly necessary. Typically this is done for performance reasons, i.e. there are currently no safe abstractions to achieve the goal safely and efficiently. The goal here is to reduce or eliminate the use of unsafe code throughout the ecosystem where it is not strictly necessary without regressing correctness or performance.
The per-crate process for this looks roughly like this:
unsafeis used in the first place.git blameusually helps with that by identifying a commit where a specific line is introduced.We want to run a lot of crates through this, so we also have some coordination tasks: