aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Schultz <karl@lunarg.com>2017-06-20 11:27:59 -0600
committerKarl Schultz <karl@lunarg.com>2017-06-20 11:27:59 -0600
commit8642911db6c4445dafb81002eecefeb46fd9ff58 (patch)
treeaa8507006852163128a298ef1700d15821f38be6
parent00399e334f7fe5766235a89ce885459ce26261f4 (diff)
downloadusermoji-8642911db6c4445dafb81002eecefeb46fd9ff58.tar.xz
demos: Destroy instance after closing Xlib connection
In the cube demos, destroy the instance after closing the display system connection. It is possible for the driver to register callback functions with a library like Xlib. If the driver is unloaded when Xlib calls those callback functions, a segfault results. Fixes #1894 Change-Id: Ieb25a00f727c4ac05ff24b41c3582b293abf4b95
-rw-r--r--demos/cube.c3
-rw-r--r--demos/cube.cpp3
2 files changed, 4 insertions, 2 deletions
diff --git a/demos/cube.c b/demos/cube.c
index ba6d53e5..a6d68a15 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -2395,7 +2395,6 @@ static void demo_cleanup(struct demo *demo) {
demo->DestroyDebugReportCallback(demo->inst, demo->msg_callback, NULL);
}
vkDestroySurfaceKHR(demo->inst, demo->surface, NULL);
- vkDestroyInstance(demo->inst, NULL);
#if defined(VK_USE_PLATFORM_XLIB_KHR)
XDestroyWindow(demo->display, demo->xlib_window);
@@ -2413,6 +2412,8 @@ static void demo_cleanup(struct demo *demo) {
wl_display_disconnect(demo->display);
#elif defined(VK_USE_PLATFORM_MIR_KHR)
#endif
+
+ vkDestroyInstance(demo->inst, NULL);
}
static void demo_resize(struct demo *demo) {
diff --git a/demos/cube.cpp b/demos/cube.cpp
index b4fd7928..3ef4f4ea 100644
--- a/demos/cube.cpp
+++ b/demos/cube.cpp
@@ -382,7 +382,6 @@ struct Demo {
device.waitIdle();
device.destroy(nullptr);
inst.destroySurfaceKHR(surface, nullptr);
- inst.destroy(nullptr);
#if defined(VK_USE_PLATFORM_XLIB_KHR)
XDestroyWindow(display, xlib_window);
@@ -400,6 +399,8 @@ struct Demo {
wl_display_disconnect(display);
#elif defined(VK_USE_PLATFORM_MIR_KHR)
#endif
+
+ inst.destroy(nullptr);
}
void create_device() {