Skip to content

Console::Poll can terminate under heap pressure while growing bounded input line #10

Description

@LK-Simon

Bug

Console::Poll() enforces ConsoleConfig::MaximumLineLength, but the backing std::string grows incrementally with push_back(). Under severe heap pressure this growth can throw std::bad_alloc; if exception allocation itself fails on ESP32, the process reaches std::terminate()/abort().

This was reproduced in EventConsole-Lab after ESP-NOW had already begun reporting allocation failures. The fatal backtrace resolved through std::string::push_back() -> ESPressio::Serial::Console::Poll() -> operator new -> std::terminate().

Expected

A configured bounded console line should allocate its bounded storage during initialization rather than introducing an avoidable allocation point while consuming an ordinary command.

Acceptance criteria

  • Reserve the configured line capacity during Console::Initialize().
  • If the reservation cannot be satisfied, initialization fails cleanly rather than leaving a partially initialized console.
  • Poll() does not need to grow the input string for lines up to MaximumLineLength.
  • Add regression coverage demonstrating that the configured capacity is established during initialization and retained through polling/clearing.
  • Preserve existing maximum-line-length/discard semantics and public API behavior.
  • Update CHANGELOG/documentation for the patch release candidate.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions