weston/.gitlab-ci
Daniel Stone 6c8ae362bb 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>
2022-07-05 10:15:49 +01:00
..
virtme-scripts CI: Never unload llvmpipe DSO whilst testing 2022-07-05 10:15:49 +01:00
build-deps.sh gitlab-ci: build libdrm version 2.4.108 from source 2022-06-07 09:34:54 +01:00
debian-install.sh doc/sphinx/doxygen.ini.in: Remove CLASS_DIAGRAM 2022-07-01 17:20:49 +03:00
leak-sanitizer.supp CI: Skip certain fontconfig leaks 2022-07-05 10:15:38 +01:00