A comment/question after investigating some stack usage protection in freeRTOS 8.2.3. This post is about tasks.c, prvAllocateTCBAndStack().
Believe the feature of allocating stack/TCB, so that stack would grow away from its TCB block was added in 8.2.0. But is really allocating TCB and stack in separate alloc steps ensuring the intended protection in all use cases?
What if one has a heap implementation that supports free? In that case, one can foresee the possibility that the allocation of the TCB and stack do not get the intended order in memory due to heap fragmentation.
Wouldn’t it be better (and possibly also simpler) to allocate the TCB and stack in one go; including required additional bytes for stack alignment if TCB is not a multiple of StackType_t?
Admittedly, I haven’t investigated all the various freeRTOS heap implementations, and this is not a problem for me; since I am not supporting free in the applications I am working with.