Skip to content

Add AddressSanitizer and UBSan support

Simon McVittie requested to merge smcv/dbus:wip/asan into master

This branch adds support for building with AddressSanitizer (ASan) and the accompanying undefined behaviour sanitizer (UBSan). It detected the bugs fixed in !41 (merged), !42 (merged), !44 (merged), !45 (merged), !46 (merged) and #234 (closed).

We can't run test-segfault with AddressSanitizer, because it deliberately segfaults. The address sanitizer catches this and turns it into an _exit() call, resulting in a test failure, because the test that runs test-segfault expects it to segfault. To get around this, I've added a SANITIZE_CFLAGS variable that enables the address sanitizer, and used it everywhere except test-segfault. I also had to move _dbus_disable_crash_handling() into its own translation unit so that test-segfault could compile its own copy.

This branch contains and requires !37 (merged), for the reasons stated in !37 (merged).

This branch will fail CI until !44 (merged) is fixed, because AddressSanitizer's memory allocation pattern (with allocations far apart in the address space) happens to trigger an assertion failure caused by the bug fixed in !44 (merged).

Edited by Simon McVittie

Merge request reports