• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * This document explain how to run analyse the virglrenderer
3 * code base using ASAN, the address sanitizer tools include
4 * in Clang and gcc.
5 */
6
7VIRGLRENDERER:
8
9Compiling virglrenderer with the following flags:
10`-fsanitize=address`
11or
12`-fsanitize=memory`
13Sadly, we can't use both of them in the same time.
14
15For example,
16```
17export CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
18export CXXFLAGS="-fsanitize=address -fno-omit-frame-pointer"
19mkdir build && cd build
20../autogen.sh --prefix=/home/user/virglrenderer/install --enable-debug
21make
22```
23
24The `-fsanitize=leak` flag don't have to be add for Linux as
25it is set by default. This flag can be add to the toolchain of other platform.
26
27
28MESA:
29
30Since mesa unloads the drivers before a program finished, but ASAN only
31resolves stack traces at the end. It is almost impossible to get meaningful
32backtraces and so check whether the culprit is mesa or virglrenderer.
33Hence, it is useful to override *dlclose* by pre-loading a shared library
34that implements a stub, e.g. like:
35```
36int dlclose(void *handle) {
37        return 0;
38}
39```
40It seems that you need to pre-load ASAN before your dummie library.
41`export LD_PRELOAD="/usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/libasan.so $HOME/libfake-dlclose.so"`
42
43
44VTEST:
45
46Then run virglrenderer with the following flag:
47`ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer`
48On platform other than Linux, `ASAN_OPTIONS=detect_leaks=1`
49should be added.
50
51Start the vtest server with the command:
52`ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer ./virgl_test_server`
53
54Then connect to the server
55```
56export LIBGL_ALWAYS_SOFTWARE=true
57export GALLIUM_DRIVER=virpipe
58```
59
60Run any payload.
61