-
Notifications
You must be signed in to change notification settings - Fork 31
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
Stack should be an unsafe trait #39
Comments
I don't understand. You can create as many arbitrary raw pointers as you want using just safe code. E.g.. https://is.gd/zhyu8t. It's dereferencing them that is unsafe. |
The issue is that Now that I look at it again, this isn't really an issue since |
I strongly disagrre with the resolution of this issue. Here is my reasoning: The whole point of The resolution of this issue proposes to not use the My suggestion is: Pretty please, with sugar lumps on top, reconsider this decision! I don't want to feel |
You cannot use a Stack (unlike a GuardedStack, which is unsafe to implement) without going through Generator::unsafe_new. The only difference is where exactly the contract is stated; the unsafe mechanism is working as intended. |
What I am saying is that the responsibility for satisfying a contract should be advertised using I am sorry for coming across as such a desperate being, but I have to confess that I have been looking forward to someone implementing this crate for more than a year now. I am so clueless when it comes to assembly that I could not even attempt. Now that the crate exists, I just feel like it should become the most awesome crate in the rust ecosystem and this is the reason why I would like to make sure that it meet the highest standards of quality. I feel like this discussion could benefit from people who are specialists in the |
FYI we've already added that |
This will be fixed by #54 |
Note that I have very little idea about the inner workings of this library. But here are my feelings on when a (public) trait should be struct T;
impl Stack for T {
fn base(&self) -> *mut u8 { 42 as *mut u8 }
fn limit(&self) -> *mut u8 { 42 as *mut u8 }
} This is a perfectly fine implementations of the interface, it does not violate any of Rust's safety assumptions. The fact that it makes little sense is independent of that. this is comparable to implementing the If it is the case that I can now subsequently call some safe functions with I hope this helps. |
As discussed above, that isn't possible: you either need to |
I was scrolling over the previous discussion, but there's lots of details of the API that I do not understand, which probably led to me not noticing these comments. Sorry for that. The Stack documentation describes a contract that has to be fulfilled by implementations of this trait, and that contract goes beyond the mere types, i.e., my dummy implementation above violates the contract. Effectively, by making I guess the situation is comparable to code that relies on |
The
Stack
trait allows returning arbitrary raw pointers which can be used to write to arbitrary addresses using only safe code.The text was updated successfully, but these errors were encountered: