CONFIG_STACK_SENTINEL

Enable stack sentinel

Type: bool

Help

Store a magic value at the lowest addresses of a thread’s stack. Periodically check that this value is still present and kill the thread gracefully if it isn’t. This is currently checked in four places:

  1. Upon any context switch for the outgoing thread

  2. Any hardware interrupt that doesn’t context switch, the check is performed for the interrupted thread

  3. When a thread returns from its entry point

  4. When a thread calls k_yield() but doesn’t context switch

This feature doesn’t prevent corruption and the system may be in an unusable state. However, given the bizarre behavior associated with stack overflows, knowledge that this is happening is very useful.

This feature is intended for those systems which lack hardware support for stack overflow protection, or have insufficient system resources to use that hardware support.

Direct dependencies

!USERSPACE

(Includes any dependencies from ifs and menus.)

Defaults

No defaults. Implicitly defaults to n.

Symbols selected by this symbol

Kconfig definition

At <Zephyr>/subsys/debug/Kconfig:144

Included via <Zephyr>/Kconfig:8<Zephyr>/Kconfig.zephyr:34<Zephyr>/subsys/Kconfig:16

Menu path: (Top) → Sub Systems and OS Services → Debugging Options

config STACK_SENTINEL
    bool "Enable stack sentinel"
    select THREAD_STACK_INFO
    depends on !USERSPACE
    help
      Store a magic value at the lowest addresses of a thread's stack.
      Periodically check that this value is still present and kill the
      thread gracefully if it isn't. This is currently checked in four
      places:

      1) Upon any context switch for the outgoing thread
      2) Any hardware interrupt that doesn't context switch, the check is
         performed for the interrupted thread
      3) When a thread returns from its entry point
      4) When a thread calls k_yield() but doesn't context switch

      This feature doesn't prevent corruption and the system may be
      in an unusable state. However, given the bizarre behavior associated
      with stack overflows, knowledge that this is happening is very
      useful.

      This feature is intended for those systems which lack hardware support
      for stack overflow protection, or have insufficient system resources
      to use that hardware support.

(The ‘depends on’ condition includes propagated dependencies from ifs and menus.)