Skip to content

fix: alloc(0) call is UB#442

Open
EmilyMatt wants to merge 5 commits intosimd-lite:mainfrom
EmilyMatt:allocation-ub
Open

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

Conversation

@EmilyMatt
Copy link
Copy Markdown
Contributor

@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

Copy link
Copy Markdown
Member

@Licenser Licenser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! good catch :)

@EmilyMatt
Copy link
Copy Markdown
Contributor Author

@Licenser Does this have anything actionable for me? or is just pending due to time limitations?

@EmilyMatt
Copy link
Copy Markdown
Contributor Author

I'm fixing CI here(some clippy warnings and wastime installation)
Will rebase the other PR (#445 ) after this is merged

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.16%. Comparing base (c18bb92) to head (3084cb7).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #442      +/-   ##
==========================================
- Coverage   72.33%   72.16%   -0.17%     
==========================================
  Files          51       49       -2     
  Lines       11435    11318     -117     
==========================================
- Hits         8271     8168     -103     
+ Misses       3164     3150      -14     
Flag Coverage Δ
unittests 72.16% <100.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@EmilyMatt
Copy link
Copy Markdown
Contributor Author

@Licenser Last two checks can't be green until merged to main (I think they will only be green in the next PRs)

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.

2 participants