Closed ivq closed 11 months ago
If portBYTE_ALIGNMENT is stricter than that of StackType_t
StackType_t is always defined according to the portBYTE_ALIGNMENT. The following are the 4 ports for which portSTACK_GROWTH > 0:
#define portSTACK_TYPE uint16_t
#define portBYTE_ALIGNMENT 2
#define portSTACK_TYPE uint8_t
#define portBYTE_ALIGNMENT 1
#define portSTACK_TYPE uint16_t
#define portBYTE_ALIGNMENT 2
#define portSTACK_TYPE uint8_t
#define portBYTE_ALIGNMENT 1
Therefore, no special alignment related adjustment is needed. Even if a new port defines the StackType_t incorrectly, the assert will catch it.
Yes, for all current ports for which portSTACK_GROWTH > 0, that's true. But I don't see any requirement on the binding of portBYTE_ALIGNMENT and StackType_t. Many ports for which portSTACK_GROWTH < 0 don't satisfy the requirement. For example:
#define portBYTE_ALIGNMENT 8
#define portSTACK_TYPE uint32_t
// RV64, non E extension
#define portBYTE_ALIGNMENT 16
#define portSTACK_TYPE uint64_t
The patch is indeed for future new ports.
The patch is indeed for future new ports.
Okay, that is reasonable.
The stack of a task could not be properly aligned if stack grows upwards(portSTACK_GROWTH > 0).
Possible call trace of the bug:
Target None. The bug is only theoretically possible.
Host Not applicable.
To Reproduce Not applicable.
Expected behavior The stack should be aligned as portSTACK_GROWTH < 0 does.
Proposed Fix https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/751