interplane.Get Omega
Read in your language

interplane-mv

INTERPLANE: open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority.

Brought by drakestapleton

branch main Branches Tags History

interplane-mv / docs / external / nightdriver / 565 / REPORT.md

79 lines · 12883 bytes Raw Blame History Source

NightDriverStrip issue 565: "Memory allocations fail in low memory situations, but too early"

Lane D2. Upstream project: PlummersSoftwareLLC/NightDriverStrip. Nothing here has been sent upstream (upstreamed is not claimed anywhere below). Pinned main: 4d79c290 (same SHA as lane D1).

Outcome: root cause NOT proven; one verified capability mismatch in a size decision (hardening, not a claimed fix for #565); real reproduction BLOCKED on a physical M5StickC Plus.

Evidence tags: observed, reproduced, inferred, hypothesized, fixed, tested, upstreamed, accepted. "Model" means a host simulation of documented ESP-IDF semantics, never the real allocator.

Observed

The issue (Dave Plummer, 2023-12-10), complete text of the claim:

Allocation and sizing path on pinned main 4d79c290:

ESP-IDF semantics (all quoted from source; ESP-IDF v5.5.2 unless stated):

Reproduction

Root Cause

Not proven. What is established (observed, from source): the project sizes its LED buffer budget from a quantity (INTERNAL, aggregate) that is not the quantity its allocator consumes (INTERNAL|8BIT, per block). What is not established: that this mismatch caused any failure in #562 or in Dave's report, and which allocation failed. The #562 thread points to a different, ordinary cause for the rebooting board: a fixed 150 kB reserve consumed at runtime by WiFi, task stacks and the web server on a board with ~180 kB free at boot (observed numbers above), plus a framework update (rbergen: ~30K). That is a capacity problem, not an allocator-decision defect.

Fix

Branch fix/565-buffer-budget-8bit on aien-spark/NightDriverStrip (fork), commit 8e3d3515c36bebea464467b7834c8ca95afe8925, based on 4d79c290. Two files: new include/heapbudget.h (FreeInternalBytes8Bit(), one heap_caps_get_free_size(INTERNAL|8BIT) call) and a 3-line change in SystemContainer::SetupBufferManagers for the non-PSRAM branch. PSRAM builds unchanged.

Regression

harness/run.sh (above), 3 cases. Red/green: the old query violates the invariant 14018 times and the new helper 0 times in the same run; negative control [tested]: the same test against a copy of the helper that queries INTERNAL only prints RESULT FAIL (3) (both recorded in harness/results.txt). Limits: the arithmetic from systemcontainer.cpp is copied into the test, not compiled from source; the heap is a model.

Instrumentation proposal (device run; nothing applied)

The decisive missing datum is the failing allocation's size and caps. IDF already provides it (heap_caps_register_failed_alloc_callback). Proposed minimal diagnostic, in project style, to be tried on a device first (untested):

  1. At boot, heap_caps_register_failed_alloc_callback(cb). The callback only stores size, caps, function_name, a failure counter and a snapshot of heap_caps_get_free_size and heap_caps_get_largest_free_block for INTERNAL, INTERNAL|8BIT, DMA, SPIRAM|8BIT into a static struct. No printing, no allocation, no locks in the callback (it runs inside the allocator; esp_heap_caps.h:68-77 warns about the neighbouring hook for the same reason).
  2. Print that struct from the existing periodic status line (main.cpp:861 area) next to LargestBlk, plus heap_caps_get_minimum_free_size(INTERNAL|8BIT) and uxTaskGetStackHighWaterMark per task where taskmgr.cpp:156 already logs thread launches.
  3. Replace ESP.getMaxAllocHeap() in those lines (or add beside it) with the INTERNAL|8BIT largest block so the logged number is the one an 8-bit allocation can use.
  4. CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS (heap_caps.c:29,55) is an sdkconfig option. Not checked whether pioarduino 55.03.37 can set it for the Arduino libraries; the callback does not need it.

Scope

INTERPLANE Lesson

Admission decisions must use the capability-qualified resource the consumer will actually draw from, not an aggregate that merely sounds like it.