Hi!

I just encountered a problem with do_stackcheck(), and wanted to ask for an opinion...

In my (PX4) software I have got some threads, who define their stack size unaligned by 4 bytes (uint32_t). The stack coloring works on uint32, and thus doesn't color the topmost bytes of the stack when the stack size is not aligned to 4.

The arm_checkstack.c: do_stackcheck() on the other hand starts the coloring check at " start = alloc & ~3;", which is actually (partially) outside the stack.

So in px4, I end up seeing stack usage 100% on some threads (in "ps"), which I want to fix. So what would be the preferred way to fix this:

1. Set the stack size as aligned already in arch/arm/src/common/arm_createstack.c:

-      tcb->adj_stack_size = stack_size;
+      tcb->adj_stack_size = STACK_ALIGN_DOWN(stack_size);

2. fix the do_stackcheck in a way that it doesn't start at (unaligned) top, but at the first aligned stack address?

3. just leave nuttx as is, and go fix all the stack sizes in px4?


Initally I did the (1.) which seems to fix my problem.


Regards,

Jukka


Reply via email to