So I'm using CMSIS-RTOS
mail-queue mechanics with Keil uVision 5.0.5
at STM32F427
microcontroller running at 180MHz
. And every now and then releasing previously allocated mailbox element with osMailFree() resulted in some address being returned instead of osStatus-type value like osOK or osErrorValue or whatever is said in the docs.
This address points to os_mailQ_p_##blahlbah element of a service structure allocated with osMailQDef. This also means it points right beyond the end of an actual data buffer allocated with the same osMailQDef macro.
All of my structures are allocated statically; stack sizes for threads (OS_STKSIZE 600) are also looking pretty enough - anyway, doubling and tripling them gave no effect.
It wouldn't bother me if it's not the fact that early or later my program comes into situation when one thread is unable to allocate a mail element (osMailAlloc() returns 0) while other, waiting thread, is constantly taking osEventTimeout. Seems like all memory blocks are in use - yet I'm honestly releasing it after every use (in wrapping object's destructor, to be sure it is truly released).
What could that mean and where to dig?