AddressSanitizer/Problems

Common problems when trying to compile Gentoo with Address Sanitizer.

Address Sanitizer errors
Some applications just read or write invalid memory or have use after free errors in their normal operation. These should all be fixed. The Address Sanitizer error message is already a very helpful analysis of such problems. The errors are logged in. To make the error messages more helpful it often makes sense to recompile applications with -g in the CFLAGS (debugging symbols) and with FEATURES="nostrip".

Libtool issues
When linking shared libraries libtool will filter the LDFLAGS and only allows known good flags. The current version of libtool is unaware of Address Sanitizer and will therefore also filter the  flag from the linker call. This breaks the compilation.

This has been fixed upstream and this fix is part of the libtool ebuild in the asantoo overlay. This fix is not part of a libtool release yet. It will take a while until this change takes effect. The problem is that the libtool scripts are bundled with applications. Therefore even if upstream libtool allows the  flag, this change has to be made on the systems of the upstream packagers.

As the number of packages affected by this is huge the asantoo-base package in the overlay installs a portage hook that will automatically patch all applications that ship an affected libtool script (the problem is in the file ltmain.sh).

pthread linking issues
Some configure scripts test the need of the  compiler flag by testing whether the function   is available without it. The Address Sanitizer library (libasan) provides this function. However it does not have a full pthread implementation, more advanced pthread functions aren't provided. Therefore the compilation fails.

A workaround is to add the  compiler flag manually, the overlay provides a package.env file which does this for some known packages with this problem.