bmarcot / vega

vega -- The Unix-like Operating System for micro-controllers (ARM Cortex-M4)
6 stars 1 forks source link

Add a canary at the end of thread struct #11

Closed bmarcot closed 7 years ago

bmarcot commented 8 years ago
-------------
struct thread {
  struct mthread mthread;
  unsinged int id
  char canary[4] = "cana";
};
-------------
^
| interrupt stack
| growing downward

On an exception, it should be possible in some cases to catch a stack overflow in the interrupt stack by checking if a canary has been clobbered.

bmarcot commented 8 years ago

Also, same idea can be used for stack profiling when building with --interrupt-stack-profiling and --thread-stack-profiling. Check how much pattern have been clobbered.

bmarcot commented 7 years ago

Added in f0a3679

bmarcot commented 7 years ago

Fixed in f0a36791bc462f8129ead6b0bb11c35adf95e1cf