diff options
author | Xuelian <xuelian.bai@samsung.com> | 2020-05-12 19:00:12 +0800 |
---|---|---|
committer | Xuelian Bai <xuelian.bai@samsung.com> | 2023-02-21 14:32:48 +0800 |
commit | 27470f329ef9d4b53e13f85af391ba5b42025d43 (patch) | |
tree | 3069107ba1e0931437f220e7bb2e077221229369 /src | |
parent | e24abfa7c562688854da97749012a9384826cf2a (diff) | |
download | mesa-27470f329ef9d4b53e13f85af391ba5b42025d43.tar.gz mesa-27470f329ef9d4b53e13f85af391ba5b42025d43.tar.bz2 mesa-27470f329ef9d4b53e13f85af391ba5b42025d43.zip |
Add exception handle for multithread case.
In some cases, main thread got some problem and exit with calling
_eglAtExit, while another thread may still be running, that will
cause assert in mesa.
Change-Id: I6ee87abcb8c818e8a6808cd6098f4061bf7779b2
Signed-Off-by: Xuelian Bai <xuelian.bai@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 7 | ||||
-rw-r--r-- | src/egl/main/egldevice.c | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index df2a13f7d46..d04ed5441c4 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -826,6 +826,13 @@ dri2_load_driver_common(_EGLDisplay *disp, struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); const __DRIextension **extensions; + /*This exception only happen in multithread case, when _eglAtExit is * + *called and disp is freed in main thread. */ + if (dri2_dpy == NULL) { + _eglLog(_EGL_FATAL, "DRI2: disp is freed"); + return EGL_FALSE; + } + extensions = dri2_open_driver(disp); if (!extensions) return EGL_FALSE; diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c index c1c421b5050..22346cafc14 100644 --- a/src/egl/main/egldevice.c +++ b/src/egl/main/egldevice.c @@ -171,6 +171,14 @@ _eglAddDevice(int fd, bool software) simple_mtx_lock(_eglGlobal.Mutex); dev = _eglGlobal.DeviceList; + /*This exception only happen in multithread case, when _eglAtExit is * + *called and _eglFiniDevice(where _eglGlobal.DeviceList is set to null)* + *is called in main thread. */ + if (dev == NULL) { + _eglLog(_EGL_FATAL, "_eglGlobal.DeviceList is freed"); + goto out; + } + /* The first device is always software */ assert(dev); assert(_eglDeviceSupports(dev, _EGL_DEVICE_SOFTWARE)); |