Skip to content

services/vibes: fix history leak and heap diagnostics - #2387

Merged
jplexer merged 2 commits into
coredevices:mainfrom
jplexer:codex/firm-4316-alarm-vibration
Oct 13, 2026
Merged

jplexer merged 2 commits into
coredevices:mainfrom
jplexer:codex/firm-4316-alarm-vibration

Conversation

@jplexer

@jplexer jplexer commented Oct 12, 2026

Copy link
Copy Markdown
Member

Stopping vibration-history collection during an active pulse can leave an unfinished entry at the head of the list. That entry blocks both clear-all and later pruning, causing retained allocations to grow with subsequent pulses. Clear unfinished entries when collection stops and protect collection transitions and event handling with the history mutex.

Also correct the largest-free-block calculation, which compared alignment units against bytes and could understate contiguous free capacity by up to four times on ARM32. This changes diagnostics; allocation and coalescing are unaffected.

These defects were found while investigating FIRM-4316. This PR is related to that issue, but is not a confirmed fix for its reported silent alarm. The alarm's root cause remains unconfirmed, and this PR should not close the issue.

Evidence for the history leak includes stale unfinished entries in the reporter's older coredump and an actual-service reproduction retaining 1,001 history allocations after 1,000 completed pulses. Regression coverage checks active-pulse cleanup, bounded growth after restarting, normal pruning, and stop/event interleavings. The allocator regression exposes a larger free block being skipped after a smaller hole.

Validation:

  • Vibration tests: 17 cases pass; allocator tests: 9 cases pass. New regressions fail before their respective fixes.
  • Vibe-score, clock, and debounced-connection test suites pass.
  • Normal QEMU Emery firmware builds with Moddable XS and speaker support enabled. Runtime/hardware validation remains outstanding.
  • Formatting, gitlint for both commits, and git diff --check pass.

@jplexer
jplexer requested a review from gmarull as a code owner October 12, 2026 13:27
jplexer and others added 2 commits October 13, 2026 13:27
Stopping accelerometer history collection during an active pulse left
an unfinished entry at the head of the list. Both clear-all and normal
pruning stopped there, so future pulses retained history allocations
until the kernel heap ran out of space.

Clear unfinished entries on shutdown and serialize collection changes
and event handling with the history mutex. This also prevents an event
from appending after shutdown or dereferencing a concurrently freed head.

Cover active-pulse cleanup, bounded growth after restarting, normal
pruning, and shutdown immediately before start/end acquire the mutex.
The 17 vibration tests pass, as do the related alarm and heap tests.
Normal QEMU Emery firmware builds with XS and speaker support enabled.

Related: FIRM-4316
The leak is confirmed; its connection to the reported silent alarm
remains unproven.

Co-authored-by: GPT-6 <noreply@openai.com>
Signed-off-by: Joshua Jun <lets@throw.rocks>
The largest-block scan compared each candidate in alignment units
against a maximum already expressed in bytes. A larger later free block
could therefore be skipped, understating contiguous capacity by up to
four times on ARM32. Allocation and coalescing are unaffected.

Compare both quantities in bytes. Add a regression with a small free
hole before a larger one, then verify complete coalescing on cleanup.
All nine allocator tests pass. The regression failed before the fix.
Normal QEMU Emery firmware also builds successfully.

Related: FIRM-4316

Co-authored-by: GPT-6 <noreply@openai.com>
Signed-off-by: Joshua Jun <lets@throw.rocks>
@jplexer
jplexer force-pushed the codex/firm-4316-alarm-vibration branch from 7a7cda6 to 3cf19af Compare October 13, 2026 11:28
@jplexer
jplexer merged commit 9759c4e into coredevices:main Oct 13, 2026
70 checks passed
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