-
Notifications
You must be signed in to change notification settings - Fork 20
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
Unsafe functions are not declared unsafe
#29
Comments
These functions are inherently unsafe regardless if you declare them unsafe or not. As a side note codebase is verified on all possible code paths using valgrind to validate that no invalid read or write is performed so library is 100% safe. P.s. note that all these functions do is read/write pointers within correct bounds |
I'm not at all saying that your code isn't correct. See https://stackoverflow.com/a/31628759 for example, maybe this explanation is better than mine. Marking unsafe functions Hope that makes sense :) |
Yes I know about semantics P.s. to clarify I do not distinguish unsafe from safe code so for me it is all the same. If someone wants to contribute, valgrind will catch their error otherwise my review will catch |
First, anyone who puts in the time and effort to open source code has done a very helpful thing. The same applies to contributing to others' open source projects. So, thank you both. The conversation above seems a bit tense. I'd like to try to bring it back to what might be the fundamental point of contention. So, I put forward this simple claim:
I offer this claim as a key starting point, in the hopes that this discussion can continue productively. |
People arrive at Rust with many different backgrounds and experience levels. The current tagline is a nice way of unifying all this variation:
Next, I want to dig into the reliable part..
How do we get (and keep) these nice things? One part is the compiler, since it enforces a lot. But we shouldn't forget another key part: shared values and norms. Some developers may not like talk of values and norms, but they are real and important. They set expectations. In the context of this particular conversation, I think the following is the key expectation:
I want to really dig into the "no matter what" language. What does that mean? Like I said above, it isn't only about the compiler. It is about what people do. Expectations help. Writing "no matter what" emphasizes the value the community places on soundness and memory safety. The aim is to cultivate a shared understanding that well-typed programs should function as expected, thereby reducing bugs and vulnerabilities. Why do we care? Because it helps the core purpose of Rust (same as above): "A language empowering everyone to build reliable and efficient software." The soundness link leads to this text:
The "undefined behavior" link leads to:
I'm sorry if this sounds a bit like a lecture! I do have a problem being long-winded. I can't tell how much of what I wrote above is being disputed here. My goal is to figure that out. My hope is that I've grounded the conversation in non-controversial fundamentals. The way they get interpreted might be in question. Let's talk about it. |
@xpe I don't know what you're trying to convey here as this library is verified using valgrind to confirm there is no invalid read or write within code. So there is no question of soundness in this code, but rather only question of using cumbersome semantics at my expense for no benefit (aside from making potential error with hidden unsafety of function not marked Maybe one day I'll make separate test suite for MIRI since it is so broken and unusable, but it wouldn't change much and soundness is proved already making issue itself no issue to me personally. |
@domenukk To speak plainly, I said what I wanted to say. Here's a summary: The early conversation seemed a bit heated; it had many of the signs of miscommunication. That's why I went back to the foundational concepts and values. If someone wants to know my take on all of the technical questions above, I don't have a comprehensive set of answers right now. I'm still assessing. In a complex conversation like this, laying out the fundamentals tends to help. It allows people to ground their claims against common points of agreement. As such, I'm glad that your response touched on the notion of soundness. So, let's get into soundness of this library:
Valgrind verification is valuable in many ways, but generally speaking, it does not prove soundness as understood in the Rust community. I'd like to add this discussion to our shared consciousness: https://www.reddit.com/r/rust/comments/s929mz/being_fair_about_memory_safety_and_performance/ |
@domenukk Returning to your top-level comment:
For the scope of this comment, I'd like to put aside the question of "who has to put in the effort to make such changes?". I'd like to both (a) drive this to conceptual bedrock and (b) understand how various Rust projects handle this concern. @domenukk To summarize, your comment says the lack of
|
It proves that all unsafe code perform correct operations (not to mention it allows to run real code rather than sub-set of code that MIRI barely supports) I run MIRI on my code and the only thing it found is dubious violation of stackful borrows and its rules are not even well defined to begin with. |
@DoumanAsh It feels like we're not on the same page with the terms and concepts here.
Valgrind is a dynamic analysis tool; as such it can not prove. It can detect particular undesirable behaviors if they occur during a particular execution (code + data + architecture). Valgrind analysis (alone) does not ensure soundness. Valgrind can't capture all types of Rust-specific Undefined Behavior (UB). See https://doc.rust-lang.org/reference/behavior-considered-undefined.html Correction: Earlier in this conversation, I should not have used the phrase "Valgrind verification". It doesn't do formal verification nor static analysis. A better phrase would be "Valgrind dynamic analysis". |
I'm not sure that we're all on the same page w.r.t. soundness versus correctness.
To decide when/where to use |
I have 100% test coverage and even if valgrind is dynamic tool, in my case it proves correctness 100% |
No, 100% test coverage (as measured over lines of code) does not prove correctness. I'm not questioning this library at this point, but your reasoning is incorrect. |
@xpe I understand all sides. As I see the library contents it's hard to say where it's incorrect. The way it was implemented is easy way to read proper amount of chunks of four ints with type If you know how to implement these functions in better way to increase |
I don't know if it's known in Rust community, Zen of Python is applicable to almost anything, and one of lines is |
Throughout the codebase a number of functions are not declared
unsafe
even though they dereference raw pointers passed in as parameters.All of the functions appear to be non-
pub
, but it still makes it hard to argue about the libraries safety.The text was updated successfully, but these errors were encountered: