Forum Discussion

oscarbaselga's avatar
oscarbaselga
Copper Contributor
May 27, 2021

[Thread X] Problem auto-filling thread stack

Hi,

 

First of all, sorry for my english!

I am making a degree project in which I am using Thread X and It is my first time working with Azure RTOS. It took me a long time to understand how Thread X and Trace X worked.

 

If I am not wrong, Thread X has a system thread called System Timer Thread that contains the "_tx_thread_priority_list" list whitin its stack. This list allocates the threads that are ready at a specific priority.

 

Well, there is an option in Thread X which allows to check the stack size in run-time and it gets enabled with the flag "TX_ENABLE_STACK_CHECKING". However, within this option appears another one that specifies if you want to initialize the stack with constants values during a thread creation in order to check how many stack memory has been used.

 

The problem is when the creation process calls "tx_thread_system_resume()" function and this one checks whether there already was an element in the corresponding entry of the "_tx_thread_priority_list". For that, it compares the value of that element with "TX_NULL" - that equals to 0. 

If we had the filling stack option enabled, we will be comparing a fake element - composed by 0xEF EF EF EF - whit 0, thus the comparison will be false provoking a Hard Fault, since we will be trying to access to an illegal memory position.

 

The solution is simple: define TX_DISABLE_STACK_FILLING flag.

 

Is this problem a bug? Or have I  made a previous mistake?

 

Regards,

Óscar

No RepliesBe the first to reply

Resources