I’ve run into a problem with uxTaskGetStackHighWaterMark() as well as vTaskGetInfo() both giving an incorrect value for the stack high-water mark sometimes (usually a single-digit number), and then eventually reporting the correct value (a higher value than before). The incorrect value is consistent between the two functions.
I’ve even been able to re-create in GDB by calling uxTaskGetStackHighWaterMark() from there, getting the wrong value, examining the stack, and calling uxTaskGetStackHighWaterMark(), at which point it gave the correct value.
Was the correct value stored in the task descriptor and the caller had received something different, or was the value in the task descriptor wrong too?
Keep in mind that the high water value only gets set at task context switch time, so if your task is consuming more time in-between, that would not be recognized.
Where would it be in the task descriptor? According to the code, it just counts it on the stack directly.
Also, the value increased, which should be impossible, since it should give the least stack ever remaining, and the fill byte should never be re-written.
It is not in the descriptor, but you can get the address of the stack from the descriptor which will let you view the stack usage in the debugger - you can also just place a break point in the code then step through the function to see exactly how it is arriving at the number it does.