Skip to content

Comments

fix: alloc(0) call is UB#442

Open
EmilyMatt wants to merge 1 commit intosimd-lite:mainfrom
EmilyMatt:allocation-ub
Open

fix: alloc(0) call is UB#442
EmilyMatt wants to merge 1 commit intosimd-lite:mainfrom
EmilyMatt:allocation-ub

Conversation

@EmilyMatt
Copy link

@EmilyMatt EmilyMatt commented Feb 24, 2026

When calling alloc(), the layout must be non-zero, otherwise we fall into undefined behaviour.
This is documented in the function's docs:
https://doc.rust-lang.org/beta/src/core/alloc/global.rs.html#152

We can just make a dangling pointer for those cases, and not deallocate it

Found by running miri on tests::test_send_sync

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant