fix(FileManager): SD log pruning caused stack-canary panic on MQTT connect task
Confirmed on hardware: enabling SD logging at INFO level caused a boot loop within seconds — "Guru Meditation Error... Stack canary watchpoint triggered (mqttConnect)". appendLogLine() was running pruneLogDirectory() (a full SD.open() directory scan + std::vector<pair<String,size_t>> build) on every single log write, and the first write happened to land on MQTTDriver's 3KB-stack connect task. Fixes: - Prune check now throttled to once per 50 writes instead of every write — removes the expensive directory scan from the hot logging path entirely. - Bumped mqttConnect/mqttRecon/mqttHB task stacks from 3072 to 4096 bytes as defense-in-depth, since these tasks can still trigger SD log writes. - Removed a LOG_INFO call inside pruneLogDirectory that could have re-entered Logging::writeToSd() from within the SD write path itself.
This commit is contained in:
@@ -345,7 +345,7 @@ void MQTTDriver::mqttReconnectTaskFn(void* param) {
|
||||
|
||||
void MQTTDriver::mqttReconnectTimerCallback(TimerHandle_t xTimer) {
|
||||
if (MQTTDriver::_instance) {
|
||||
xTaskCreate(mqttReconnectTaskFn, "mqttRecon", 3072, MQTTDriver::_instance, 5, NULL);
|
||||
xTaskCreate(mqttReconnectTaskFn, "mqttRecon", 4096, MQTTDriver::_instance, 5, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ void MQTTDriver::heartbeatTimerCallback(TimerHandle_t xTimer) {
|
||||
if (MQTTDriver::_instance->_heartbeatTaskHandle != nullptr) {
|
||||
return;
|
||||
}
|
||||
xTaskCreate(mqttHeartbeatTaskFn, "mqttHB", 3072, MQTTDriver::_instance, 3,
|
||||
xTaskCreate(mqttHeartbeatTaskFn, "mqttHB", 4096, MQTTDriver::_instance, 3,
|
||||
&MQTTDriver::_instance->_heartbeatTaskHandle);
|
||||
}
|
||||
}
|
||||
@@ -469,7 +469,7 @@ void MQTTDriver::mqttConnectTaskFn(void* param) {
|
||||
void MQTTDriver::networkStabilizationTimerCallback(TimerHandle_t xTimer) {
|
||||
if (MQTTDriver::_instance) {
|
||||
// Defer to a task — timer callbacks run in Tmr Svc (2KB stack), not enough for connect()
|
||||
xTaskCreate(mqttConnectTaskFn, "mqttConnect", 3072, MQTTDriver::_instance, 5, NULL);
|
||||
xTaskCreate(mqttConnectTaskFn, "mqttConnect", 4096, MQTTDriver::_instance, 5, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user