Skip to content

magneto: fail cleanly when out of memory - #157

Closed
ViezeVingertjes wants to merge 1 commit into
SlimeVR:devfrom
ViezeVingertjes:fix-magneto-alloc-guard
Closed

ViezeVingertjes wants to merge 1 commit into
SlimeVR:devfrom
ViezeVingertjes:fix-magneto-alloc-guard

Conversation

@ViezeVingertjes

Copy link
Copy Markdown

magneto_current_calibration makes ~27 unchecked k_malloc calls (~1KB peak) from the 2KB system heap pool. Under heap pressure it wrote through NULL and hard-faulted mid mag calibration (#89). Check every allocation, unwind and return nonzero with BAinv untouched, and stop ignoring the Hessenberg_Form_Elementary return values. Callers log the failure and keep the previous calibration.

Host-tested with fault injection at every allocation index: clean error return, nothing leaked, output never touched.

magneto_current_calibration makes ~27 unchecked k_malloc calls (~1KB
peak) from the 2KB system heap pool. Under heap pressure it wrote
through NULL and hard-faulted mid mag calibration (#89). Check every
allocation, unwind and return nonzero with BAinv untouched, and stop
ignoring the Hessenberg_Form_Elementary return values. Callers log the
failure and keep the previous calibration.

Host-tested with fault injection at every allocation index: clean error
return, nothing leaked, output never touched.
@ViezeVingertjes
ViezeVingertjes marked this pull request as ready for review August 5, 2026 18:34
@ViezeVingertjes
ViezeVingertjes changed the base branch from main to dev August 5, 2026 18:42
@sctanf

sctanf commented Aug 6, 2026

Copy link
Copy Markdown
Member

almost nothing uses the system heap, and they also do not use heap at the same time; so this is not necessary

@ViezeVingertjes

ViezeVingertjes commented Aug 6, 2026 •

Copy link
Copy Markdown
Author

almost nothing uses the system heap, and they also do not use heap at the same time

Which is true, but it's cumulative and it happens rather quickly <10 minutes, is quite invisible and only a reset fixes it. These are just fragments of my personal fork seperated, so might be surfacing more quickly in my version but its certainly in upstream, so wouldnt hurt imho.

But if it isnt an issue (yet), feel free to close it, when it comes one its still in the history.

@ViezeVingertjes ViezeVingertjes closed this by deleting the head repository Aug 7, 2026
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