diff options
author | Daniel Stone <daniels@collabora.com> | 2022-06-25 04:59:52 +0100 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2022-07-05 10:15:49 +0100 |
commit | 6c8ae362bb3b93a260d38fb9829183c025dc4948 (patch) | |
tree | 5179b4da0d2474975cfe15c303c93bec788390ce /.gitlab-ci | |
parent | c5ed892b1b524b85a741a52a4afc99190c9f0c49 (diff) |
CI: Never unload llvmpipe DSO whilst testing
This commit is truly horrible.
We want to run ASan with leak checking enabled in CI so we can catch
memory leaks before they're introduced. This works well with Pixman, and
with NIR-only drivers like iris or Panfrost.
But when we run under llvmpipe - which we do under CI - we start failing
because:
- Mesa pulls in llvmpipe via dlopen
- llvmpipe pulls in LLVM itself via DT_NEEDED
- initialising LLVM's global type/etc systems performs thread-local
allocations
- llvmpipe can't free those allocations since the application might
also be using LLVM
- Weston stops using GL and destroys all GL objects, leading to Mesa
unloading llvmpipe like it should
- with everything disappearing from the process's vmap, ASan can no
longer keep track of still-reachable pointers
- tests fail because LLVM is 'leaking'
Usually, an alternative is to LD_PRELOAD a shim which overrides
dlclose() to be a no-op. This is not usable here, because when
$LD_PRELOAD is not empty and ASan is not first in it, ASan immediately
errors out. Prepending ASan doesn't work, because we run our tests
through Meson (which also invokes Ninja), leading to LSan exploding
over CPython and Ninja, which is not what we're interested in.
It would be possible to inject _both_ ASan and a dlclose-does-nothing
shim DSO into the LD_PRELOAD environment for every test, but that seems
even worse, especially as Meson strongly discourages globbing for random
files in the root.
So, here we are, doing what we can: finding where swrast_dri.so (aka
llvmpipe) lives, stashing that in an environment variable, and
deliberately leaking a dlopen handle which we never close to ensure that
neither llvmpipe nor LLVM leave our process's address space before we
exit.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to '.gitlab-ci')
-rwxr-xr-x | .gitlab-ci/virtme-scripts/run-weston-tests.sh | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/.gitlab-ci/virtme-scripts/run-weston-tests.sh b/.gitlab-ci/virtme-scripts/run-weston-tests.sh index 2b156333..c61bd615 100755 --- a/.gitlab-ci/virtme-scripts/run-weston-tests.sh +++ b/.gitlab-ci/virtme-scripts/run-weston-tests.sh @@ -28,6 +28,10 @@ export PATH=/usr/local/bin:$PATH export SEATD_LOGLEVEL=debug +# Terrible hack, per comment in weston-test-runner.c's main(): find Mesa's +# llvmpipe driver module location +export WESTON_CI_LEAK_DL_HANDLE=$(find /usr/local -name swrast_dri.so -print 2>/dev/null || true) + # run the tests and save the exit status # we give ourselves a very generous timeout multiplier due to ASan overhead echo 0x1f > /sys/module/drm/parameters/debug |