diff --git a/meson.build b/meson.build index f828eb80faa..d866e7313cb 100644 --- a/meson.build +++ b/meson.build @@ -1648,6 +1648,15 @@ else dep_valgrind = null_dep endif +# AddressSanitizer's leak reports need all the symbols to be present at exit to +# decode well, which runs afoul of our dlopen()/dlclose()ing of the DRI drivers. +# Set a flag so we can skip the dlclose for asan builds. +if ['address', 'address,undefined'].contains(get_option('b_sanitize')) + asan_c_args = ['-DBUILT_WITH_ASAN=1'] +else + asan_c_args = ['-DBUILT_WITH_ASAN=0'] +endif + # pthread stubs. Lets not and say we didn't if host_machine.system() == 'windows' diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 89fc1c8997e..d2febce7639 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1237,8 +1237,15 @@ dri2_display_destroy(_EGLDisplay *disp) } if (dri2_dpy->fd >= 0) close(dri2_dpy->fd); + + /* Don't dlclose the driver when building with the address sanitizer, so you + * get good symbols from the leak reports. + */ +#if !BUILT_WITH_ASAN || defined(NDEBUG) if (dri2_dpy->driver) dlclose(dri2_dpy->driver); +#endif + free(dri2_dpy->driver_name); #ifdef HAVE_WAYLAND_PLATFORM diff --git a/src/egl/meson.build b/src/egl/meson.build index 69f9484e6c9..7a3fcdca157 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build @@ -21,7 +21,7 @@ inc_egl = include_directories('.', 'main') inc_egl_dri2 = include_directories('drivers/dri2') -c_args_for_egl = [] +c_args_for_egl = [asan_c_args] link_for_egl = [] deps_for_egl = [] incs_for_egl = [inc_include, inc_src, inc_egl]