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

Work towards removing malloc_buf #547

Merged
merged 3 commits into from
Dec 27, 2023
Merged

Work towards removing malloc_buf #547

merged 3 commits into from
Dec 27, 2023

Conversation

madsmtm
Copy link
Owner

@madsmtm madsmtm commented Dec 27, 2023

malloc_buf is unmaintained and unsound, and may be marked as such in the Rustsec Advisory Database in the future, which would be bad for our users; so we should really migrate to something else.

The alternatives mbox, malloced and malloc-array are either also unsound (usually failing to handle 0-length arrays properly), or not popular/maintained enough for me to be comfortable with them as a dependency.

So let's just roll our own implementation, it's not really that complex anyhow (since we don't handle allocation, only deallocation), and we should be able to swap it out with Box<_, MallocAllocator> in the future.

Part of #500.

@madsmtm madsmtm added enhancement New feature or request A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates labels Dec 27, 2023
@madsmtm madsmtm marked this pull request as ready for review December 27, 2023 01:42
@madsmtm madsmtm mentioned this pull request Dec 27, 2023
2 tasks
@madsmtm madsmtm force-pushed the deprecate-malloc-buf branch 2 times, most recently from 4ec0358 to 9db2b06 Compare December 27, 2023 04:02
@madsmtm madsmtm merged commit ff4a4c1 into master Dec 27, 2023
19 checks passed
@madsmtm madsmtm deleted the deprecate-malloc-buf branch December 27, 2023 13:53
@madsmtm
Copy link
Owner Author

madsmtm commented Dec 27, 2023

Note that this added objc_sys::free, to avoid the dependency on libc. I did first investigate if System.dealloc could be used for this, since that calls libc::free internally, but you probably can't rely on that.

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 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant