-
Notifications
You must be signed in to change notification settings - Fork 7
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
Soundess issues #3
Comments
Wow, so many feedback :) Thank you! I will start with last one:
There is not leak here. I was thinking how to proper model Lines 110 to 114 in c6160b4
See Yes it doubles API's, but user can decide to go with |
That's true for most selectors, but since the selector |
I.e. you don't need to |
Btw, the reason I've mostly avoided using autoreleased references (apart from ergonomics) is that they're as far as I could find out, slower than doing the retain/release with (Do note that these measurements were made a while ago, and on older hardware, so details may vary on your device). |
Yep, you right about new. Will fix it. Thank you. |
About first one. I wanna to do |
Yeah, I understand, and it is sound for some classes, but not for others. The solution I've gone with is to "classify" ever type as (basically) either mutable or using interior mutability. So e.g. In turn, this allows See the This is probably not the only option, so feel free to experiment with others! |
Also, your solution for autoreleased references is not enough, e.g. one could just do the following instead: use cidre::{ns, objc};
let s = ns::String::with_str("My String");
let lowercased;
objc::ar_pool(|| {
lowercased = s.lowercased_ar();
// The newly created string is released and deallocated here
});
// But we can still use it here
println!("{lowercased}"); See |
From a quick skim, I found the following important safety mistakes, that leads to unsound code (unsoundness = a safe abstract which a downstream user can use to violate memory safety without writing
unsafe
themselves).Note that I completely understand the reasoning behind these mistakes, most have only been fixed in
objc2
very recently!arc::Retain<T>
allows access to&mut T
(throughDerefMut
), which is not safe for almost all classes.Autoreleased references are not bound to a pool, meaning that they can be accessed after they've been reclaimed by the pool.
Message sending to methods in the
new
family leaks, sincenew
returns an object with +1 retain count.The text was updated successfully, but these errors were encountered: