These are chat archives for SmingHub/Sming
Here is what I have found regarding my problem "DelegateTask"(stack_size = 2,task handle = 3fff3548) overflow the heap_size.
I dug into the code of RTOS to find anything which might shed light on it, and saw
that "DelegateTask" is an RTOS task created inside the HardwareSerial class constructor, and is responsible for receiving characters. I can see that there is a check on the stack which happens on each context switch.
I am not creating any RTOS tasks myself, nor am I calling anything to get characters from the serial port,
but I do expect RTOS to switch to the DelegateTask and block on xQueueReceive, just once.
When it does so, I get my error message - "DelegateTask"(stack_size = 2,task handle = 3fff3548) overflow the heap_size.
Being new to RTOS and fairly new to ESP8266 means I'm guessing a fair bit here.
So now I know I have overwritten memory somehow. If there are techniques anyone uses to find memory overwrites etc, pls share them.
In the end I resorted to removing functionality bit by bit until the error went away.
By doing so, the finger is firmly pointed at the prettyPrintTo function. After commenting out this code:
const uint16_t ConfigFileBufferSize = 3048;
my memory corruption error message is gone.
The issue is not in the prettyPrintTo function but in the way you make the call.
By using char buf you are taking 3048 bytes of stack which is way to high.
If you update to
char* buf = new char; root.prettyPrintTo(buf,3048); ... ... delete(buf);
You will most probably have fixed your issue.
RTOS is sensitive on using stacksize. In your application you should only be using the char buf[..] for small values;