summaryrefslogtreecommitdiff
path: root/src/egl/drivers/dri2/egl_dri2.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2020-11-17 16:50:36 -0800
committerMarge Bot <eric+marge@anholt.net>2020-12-02 20:43:33 +0000
commit661b29283425c568d1fa403be703775e02c50d08 (patch)
tree369e169aef80bae7c63412a024f8b4ec550f0429 /src/egl/drivers/dri2/egl_dri2.c
parent9cc8fc7bbc4a4d7fe4d3635be207daf2a6672662 (diff)
egl: Skip closing drivers when building with AddressSanitizer.
If you dlclose your driver, the leak reports look like: #0 0xffff9c7e5e7c in malloc (/lib/aarch64-linux-gnu/libasan.so.6+0x9ee7c) #1 0xffff94aaaa48 (<unknown module>) #2 0xffff94aa5ff4 (<unknown module>) #3 0xffff94d1867c (<unknown module>) #4 0xffff94d184f0 (<unknown module>) #5 0xffff94c9a990 (<unknown module>) #6 0xffff94c92e30 (<unknown module>) #7 0xffff94c91d48 (<unknown module>) #8 0xffff946eb800 (/home/anholt/src/mesa/build-aarch64-asan/src/egl/libEGL.so.1.0.0+0xfe800) #9 0xffff94c72874 (<unknown module>) #10 0xffff946ede68 (/home/anholt/src/mesa/build-aarch64-asan/src/egl/libEGL.so.1.0.0+0x100e68) #11 0xffff94bf7134 (<unknown module>) #12 0xffff9c686450 in dri2_create_screen ../src/egl/drivers/dri2/egl_dri2.c:1079 which is not terribly useful. Probe if we're building with asan and just skip closing the driver in the happy path (which seems to be the standard practice for loadable modules with this tool). Acked-by: Michel Dänzer <mdaenzer@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7695>
Diffstat (limited to 'src/egl/drivers/dri2/egl_dri2.c')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c7
1 files changed, 7 insertions, 0 deletions
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