Stack overflow in task that doesn't run
Posted: Wed Apr 25, 2018 8:07 pm
I get a stack overflow in a task with the below code. It takes about 20s before this happens. Note that await_app_event() never returns.
I saw many stack overflows in other tasks, and I raised the stacksize memory allowance to resolve these errors, despite these tasks doing very little. The allowance needed seems to be way higher than is used only for a task. Why is that? 2k is enough to run a full app on a regular MCU, and not enough for a task that does... nothing?
The only excuses I can think of are:
- interrupts. But even the few ISRs I have do not use local variables.
- runaway stack. But the task would need to run, not wait for an event.
I once saw a define for the minimal stack size value somewhere, if I remember correctly it was 768B. I'm way above that value here.
So what's the deal here??
I saw many stack overflows in other tasks, and I raised the stacksize memory allowance to resolve these errors, despite these tasks doing very little. The allowance needed seems to be way higher than is used only for a task. Why is that? 2k is enough to run a full app on a regular MCU, and not enough for a task that does... nothing?
The only excuses I can think of are:
- interrupts. But even the few ISRs I have do not use local variables.
- runaway stack. But the task would need to run, not wait for an event.
I once saw a define for the minimal stack size value somewhere, if I remember correctly it was 768B. I'm way above that value here.
So what's the deal here??
Code: Select all
EventBits_t await_app_event(u32 event) {
return xEventGroupWaitBits(app_events, event, 1, 0, RTOS_WAIT_FOREVER);
}
void radio_task() {
while(1) {
EventBits_t eventResult = await_app_event(EVENT_PACKET_RECEIVED);
if (eventResult & EVENT_PACKET_RECEIVED) {
vTaskDelay(10);
}
}
}
void radio_task_init(UBaseType_t priority) {
xTaskCreate(radio_task, "radio", 2048, NULL, priority, NULL);
}