Skip to content
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

Soundness of autorelease pools #540

Closed
madsmtm opened this issue Dec 11, 2023 · 1 comment
Closed

Soundness of autorelease pools #540

madsmtm opened this issue Dec 11, 2023 · 1 comment
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates I-unsound A soundness hole

Comments

@madsmtm
Copy link
Owner

madsmtm commented Dec 11, 2023

Autoreleasing objects using rc::autoreleasepool is unsound because we cannot ensure that the lifetime from an outer pool is not used inside an inner pool.

To help mitigate that, we provide the auto trait AutoreleaseSafe, which can be enabled with the "unstable-autoreleasesafe" feature (requires nightly, since auto traits are unstable).

Even with that, though, other libraries such as scoped-tls-hkt make assumptions that break our assumptions, see the code example provided here.

So we need some other way to make autorelease pools safe (or resort to marking them unsafe).

@madsmtm madsmtm added A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates I-unsound A soundness hole labels Dec 11, 2023
@madsmtm madsmtm added this to the objc2 v0.6 milestone May 20, 2024
@madsmtm
Copy link
Owner Author

madsmtm commented Sep 12, 2024

In df74063, I've gone with making the construction of references into the autorelease pool (like NSString::to_str and Retained::autorelease) unsafe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates I-unsound A soundness hole
Projects
None yet
Development

No branches or pull requests

1 participant