Skip to content

Work towards removing malloc_buf#547

Merged
madsmtm merged 3 commits into
masterfrom
deprecate-malloc-buf
Dec 27, 2023
Merged

Work towards removing malloc_buf#547
madsmtm merged 3 commits into
masterfrom
deprecate-malloc-buf

Conversation

@madsmtm
Copy link
Copy Markdown
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 force-pushed the deprecate-malloc-buf branch from 9db2b06 to ba3b5be Compare December 27, 2023 13:27
@madsmtm madsmtm merged commit ff4a4c1 into master Dec 27, 2023
@madsmtm madsmtm deleted the deprecate-malloc-buf branch December 27, 2023 13:53
@madsmtm
Copy link
Copy Markdown
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