Exception and Error Handling
SPDX-License-Identifier: Apache-2.0
The Zephyr RTOS shall provide a default handler for each CPU exception defined by the underlying architecture.
The Zephyr RTOS shall provide a default fatal error handler.
When an exception is handled by the default exception handler, the Zephyr RTOS shall treat the exception as a fatal error.
The Zephyr RTOS shall allow an application to provide, at build time, its own fatal error handler in place of the default handler.
The Zephyr RTOS shall provide a mechanism for software to raise a fatal error attributed to the current execution context.
The Zephyr RTOS shall provide a mechanism for software to raise a fatal error that is treated as unrecoverable.
When a fatal error handler is invoked, the Zephyr RTOS shall provide a reason code identifying the type of error.
When a fatal error is handled by the default fatal error handler, the Zephyr RTOS shall halt the system.
Where reset on fatal error is enabled, when a fatal error is handled by the default fatal error handler, the Zephyr RTOS shall reset the system instead of halting it.
When the application-provided fatal error handler returns following a recoverable fatal error attributed to a thread, the Zephyr RTOS shall terminate the offending thread and continue operation.
Where kernel assertions are enabled, when the application-provided fatal error handler returns following an unrecoverable fatal error, the Zephyr RTOS shall halt the system.
If a fatal error other than a thread stack overflow occurs in interrupt context, then the Zephyr RTOS shall treat the error as unrecoverable.
Where exception dump output is enabled, when a fatal error occurs, the Zephyr RTOS shall report diagnostic information identifying the reason for the error and the execution context in which it occurred.