Chapter 4. API Guides
UBSAN output When UBSAN detects an error, a message and the backtrace are printed, for example:
Undefined behavior of type out_of_bounds
Backtrace:0x4008b383:0x3ffcd8b0 0x4008c791:0x3ffcd8d0 0x4008c587:0x3ffcd8f0␣
,→0x4008c6be:0x3ffcd950 0x400db74f:0x3ffcd970 0x400db99c:0x3ffcd9a0
When using IDF Monitor, the backtrace will be decoded to function names and source code locations, pointing to the
location where the issue has happened (here it is main.c:128):
0x4008b383: panic_abort at /path/to/esp-idf/components/esp_system/panic.c:367
0x4008c791: esp_system_abort at /path/to/esp-idf/components/esp_system/system_api.
,→c:106
0x4008c587: __ubsan_default_handler at /path/to/esp-idf/components/esp_system/
,→ubsan.c:152
0x4008c6be: __ubsan_handle_out_of_bounds at /path/to/esp-idf/components/esp_system/
,→ubsan.c:223
0x400db74f: test_ub at main.c:128
0x400db99c: app_main at main.c:56 (discriminator 1)
The types of errors reported by UBSAN can be as follows:
Name Meaning
type_mismatch,
type_mismatch_v1
Incorrect pointer value: null, unaligned, not compatible with the
given type.
add_overflow, sub_overflow,
mul_overflow, negate_overflow
Integer overflow during addition, subtraction, multiplication, nega-
tion.
divrem_overflow Integer division by 0 or INT_MIN.
shift_out_of_bounds Overflow in left or right shift operators.
out_of_bounds Access outside of bounds of an array.
unreachable Unreachable code executed.
missing_return Non-void function has reached its end without returning a value
(C++ only).
vla_bound_not_positive Size of variable length array is not positive.
load_invalid_value Value of bool or enum (C++ only) variable is invalid (out of
bounds).
nonnull_arg Null argument passed to a function which is declared with a non-
null attribute.
nonnull_return Null value returned from a function which is declared with re-
turns_nonnull attribute.
builtin_unreachable __builtin_unreachable function called.
pointer_overflow Overflow in pointer arithmetic.
4.13 Flash Encryption
This is a quick start guide to ESP32-S2’s flash encryption feature. Using an application code example, it demonstrates
how to test and verify flash encryption operations during development and production.
4.13.1 Introduction
Flash encryption is intended for encrypting the contents of the ESP32-S2’s off-chip flash memory. Once this feature
is enabled, firmware is flashed as plaintext, and then the data is encrypted in place on the first boot. As a result, physical
Espressif Systems 1342
Submit Document Feedback
Release v4.4