AUTOSAR C++14 Rule A15-0-7
Exception handling mechanism shall guarantee a deterministic worst-case time execution time
Since R2022a
Description
Rule Definition
Exception handling mechanism shall guarantee a deterministic worst-case time execution time.
Rationale
Compilers, such as GCC or CLang, use dynamic memory allocation in the implementations of their exception handling mechanism. Dynamic memory allocation during exception handling results in a nondeterministic worst-case execution time. Such exception handling functions might raise memory allocation errors during run time. Avoid dynamic memory allocation in exception handling functions. Implement the exception handling functions so that memory is allocated before the run time.
Polyspace Implementation
Violations of this rule are raised when the exception handling functions in your code allocates or deallocates memory dynamically. Polyspace® recognizes the commonly used dynamic memory allocation functions and exception handling functions, including:
__cxa_allocate_exception
__cxa_throw
__cxa_free_exception
__cxa_begin_catch
__cxa_end_catch
Stack unwinding functions, such as
_Unwind_RaiseException
,_Unwind_Resume
,_Unwind_DeleteException
.
To check user-defined exception handling implementations, specify the
user-defined exception handling and dynamic memory managing functions by using the analysis
option -code-behavior-specifications
. In the
code behavior specification XML file, specify a function as an exception handling function
by using the behavior EXCEPTION_HANDLING
. Specify a function as a dynamic
memory managing function by using the behavior MANAGES_MEMORY
.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Exception handling |
Category: Required, Partially automated |
Version History
Introduced in R2022a