CI: Option for requiring LD_PRELOAD=asan for running tests
Closed, ResolvedPublic

Description

Provide an option/ in the build settings where for each product can be controlled if "LD_PRELOAD=asan" (or what exactly needs to be used here, plase ask aacid for details) should be used when running the tests.

This option would be false by default and set to true for the (few) projects which need that.

Motivation:
The usage of ASAN seems to be viral: when a product P built on CI links to another product L built on CI that got ASAN linked into it, product P also needs to link to ASAN in a certain way. Possibly at least to ensure it is the very first lib that is linked to by the loader.

Currently that works for most products magically, as they use CMake and ECM's KDECompilerSettings.cmake, which also pulls in ECMEnableSanitizers.cmake, where the cmake parameter ECM_ENABLE_SANITIZERS is handled and results in the proper linker/compiler setup.

But if project P is not including ECMEnableSanitizers.cmake/KDECompilerSettings.cmake, because it sees to avoid ECM dependencies or does not use cmake (people are allowed to do strange things :) ), things fail. Like currently at least happening with the Marble tests, because Marble includes ECM only in its KF5-depending subdirs and not for the tests
(patch up for review to change this to include ECMEnableSanitizers.cmake, but the principle still holds, especially given KDE growing away from Qt5/KF5 centrism)

See related discussion on kde-core-devel, "KDE CI enforcing ECMEnableSanitizers.cmake/KDECompilerSettings.cmake":
https://marc.info/?t=146157489200004&r=1&w=2

Adding people to help me understand. Sorry I am not a C++ programmer.

What exactly do I need to add to where? Is LD_PRELOAD=asan added to the CMAKE command or ?

Thanks

aacid added a comment.Apr 29 2016, 8:33 AM

It's an environment variable

I.e if you were running xenial on an amd64 machine you'd do

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.2.0.0

before running stuff.

If we just do it for marble i guess that's better for now, otherwise i *think* it doesn't really matter if we do it for all apps.