Remove disable_loop from init_log_buffer_ to avoid ESP_LOGVV before global_logger is set

Since init_log_buffer_ is now called from the constructor (before
pre_setup sets global_logger), calling disable_loop() would trigger
ESP_LOGVV which dereferences the null global_logger pointer.

The loop self-disables on its first iteration when no messages are
found, so the explicit disable in init_log_buffer_ was unnecessary.
This commit is contained in:
J. Nick Koston
2026-03-21 16:58:55 -10:00
parent cbea4e0ccf
commit b0e6f57bc2
+3 -8
View File
@@ -170,16 +170,11 @@ this->main_thread_ = pthread_self();
}
#ifdef USE_ESPHOME_TASK_LOG_BUFFER
void Logger::init_log_buffer_(size_t total_buffer_size) {
// Host uses slot count instead of byte size
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory) - allocated once, never freed
this->log_buffer_ = new logger::TaskLogBuffer(total_buffer_size);
#if !(defined(USE_ZEPHYR) && defined(USE_LOGGER_UART_SELECTION_USB_CDC))
// Start with loop disabled when using task buffer
// The loop will be enabled automatically when messages arrive
// Zephyr with USB CDC needs loop active to poll port readiness via cdc_loop_()
this->disable_loop_when_buffer_empty_();
#endif
// Note: we don't call disable_loop_when_buffer_empty_() here because this is called
// from the constructor before the component is registered with App. The loop will
// self-disable on its first iteration when it finds no messages to process.
}
#endif