-
Notifications
You must be signed in to change notification settings - Fork 275
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
Document **all** safety requirements or remove undocumented unsafe
functions from public API
#544
Comments
We also need to be super careful in future reviewing patches to functions with safter docs that the docs don't go stale. I was a bit worried about this when I wrote docs that are based on line-by-line parts of the function, they are begging to go stale. |
Well, in fairness, it's more like "they're useless unless you read all the source, including the C source, and you know all the UB rules for both languages and you're logically omniscient" ;). But I agree, we absolutely should fix this. |
Currently we have a wildcard on safety requirements, saying more or less "plus a bunch of other stuff we don't mention". This is not helpful. Attempt to fully describe the safety requirements of creating a context from a raw context (all, signing only, and verification only). Fix: rust-bitcoin#544
Currently we have a wildcard on safety requirements, saying more or less "plus a bunch of other stuff we don't mention". This is not helpful. Attempt to fully describe the safety requirements of creating a context from a raw context (all, signing only, and verification only). Fix: rust-bitcoin#544
Currently we have a wildcard on safety requirements, saying more or less "plus a bunch of other stuff we don't mention". This is not helpful. Attempt to fully describe the safety requirements of creating a context from a raw context (all, signing only, and verification only). Fix: rust-bitcoin#544
Currently we have a wildcard on safety requirements, saying more or less "plus a bunch of other stuff we don't mention". This is not helpful. Attempt to fully describe the safety requirements of creating a context from a raw context (all, signing only, and verification only). Fix: rust-bitcoin#544
Currently we have a wildcard on safety requirements, saying more or less "plus a bunch of other stuff we don't mention". This is not helpful. Attempt to fully describe the safety requirements of creating a context from a raw context (all, signing only, and verification only). Fix: rust-bitcoin#544
Currently we have a wildcard on safety requirements, saying more or less "plus a bunch of other stuff we don't mention". This is not helpful. Attempt to fully describe the safety requirements of creating a context from a raw context (all, signing only, and verification only). Fix: rust-bitcoin#544
e705bcf Fully describe safety requirements (Tobin C. Harding) Pull request description: Currently we have a wildcard on safety requirements, saying more or less "plus a bunch of other stuff we don't mention". This is not helpful. Attempt to fully describe the safety requirements of creating a context from a raw context (all, signing only, and verification only). Fix: #544 ## Note This is best effort only, will require some thought to review. To do this I read https://doc.rust-lang.org/reference/behavior-considered-undefined.html and then I flicked through `depend/secp256k1/src/secp256k1.c` and `util.h` to look for things that could cause things in the linked to list of UB. ACKs for top commit: apoelstra: ACK e705bcf Kixunil: ACK e705bcf Tree-SHA512: 0180d196f6d528e3c7a06da54ef58d015df19c351d98030453ae5c5e62e0565797b06169f27f5d8b40ea0b9adba377cadd45dd306c8213d0bdc98b20651766c7
Several
unsafe
functions have this in their Safety documentation:Which is essentially same as saying: "if you don't obey secret rules this is UB" and since the code can never guarantee obeying secret safety rules it's equivalent to
core::hint::unreachable_unchecked
but without improved performance.In other words those functions are totally useless.
Thus I propose for each function to either document all the rules (and make really, really sure they are correct) or just remove it from API if the rules can not be guaranteed.
The text was updated successfully, but these errors were encountered: