I am trying to use the experimental task manager of the nrf52sdk, version 17.1.0. I've come across what I would call a bug, but there might be a reasoning behind it, so that's what's bringing me here. I estimate I can convey the issue without a minimal working example and instead describe the issue.
Consider the following scenario, where there are stack allocations followed by a call to task_manager_start():
int main(int argc, char** argv) {
// stack allocations
task_manager_start(someIdleTask, nullptr);
}
In task_manager_start, at line 249 of task_manager.c there is the following code:
__set_MSP((uint32_t)(STACK_TOP));
This resets the stack pointer to the top of the stack, causing all memory allocated in the stack frame of main() to be overwritten when an interrupt is invoked. Removing the line avoids that.
In the documentation of the experimental task manager it does say "Main stack used for interrupts", but it does not say that any memory allocated in main() will be overwritten. Is this by design? I would argue that it would be better to leave the main stack as-is and simply have interrupts push a frame on the existing stack.