-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix and improve init/destroy & Blosc2Guard #34
Conversation
Thanks for taking a look - I'm not sure that this is enough though. For example, it is still possible to call |
That's not my responsibility as far as I can see. If the user wants to avoid the overhead of synchronization provided by |
To my knowledge: If you provide a "safe" public API, and that API can be called in a way that causes memory unsafe things to happen, then that is a bug since it violates the invariants that must be upheld if you only use safe code. |
I'm happy to have a PR, I'm either incapable or not competent enough to fix this it seems. |
As far as I can tell, exposing the non-context-based C APIs on the Rust side is just inherently unsafe. For example, I think the only way to make these APIs safe to use on the Rust side would be to wrap them in a But at this point, you'd have basically re-implemented the context-based C API in Rust, so I'm not sure if that would even be worthwhile. |
How's about a more emphasized warning/disclaimer that this is "safe", so long as one either uses the context API or remembers to handle the initialization and cleanup, either by the provided safe synchronization wrappers or on their own w/ the unsafe direct calls. Would that be an okay compromise? |
I don't think that's enough. The non-context APIs currently violate invariants that are assumed by the Rust compiler (for example, they make it easy to read / write global memory without synchronization). To my knowledge, this means that it's possible that the Rust compiler will just generate broken programs because it assumes that the invariants are upheld by all safe functions, when they are not. EDIT: It looks like |
Sounds like a disclaimer along the lines of "don't use this crate" is needed then. 😉 |
I can prepare an "informational" advisory for the rustsec database, if that helps? |
Will close #32