Check for undefined behaviour
Note: Running a program using UBSAN will incur in a small runtime cost.
To build NeoMutt with the Undefined Behaviour sanitizer, you need to add a option to the compiler and linker. The simplest way is to:
./configure --ubsan [OPTIONS]
make
Alternatively, you can specify additional build flags:
export EXTRA_CFLAGS="-fsanitize=undefined"
export EXTRA_LDFLAGS="-fsanitize=undefined"
./configure [OPTIONS]
make
There are further options that allows you to select specific groups of warnings, while disabling others. If you really want to dabble with this, please check the documentation on the Clang site.
Now, run NeoMutt as normal.
If there are undefined behaviour issues, you’ll see messages during runtime starting with runtime error:
, otherwise no error has been found on the current execution path.
Here’s a sample output found by gahr
during an initial run of this sanitizer:
imap/mdata.c:117:28: runtime error: load of misaligned address 0x00080402dfc6 for type 'uint32_t' (aka 'unsigned int')