Howdy!
I’ve discovered that I can reliably make my game crash by altering the display settings that cause the window handle to be destroyed and recreated. The window recreation works for the first three times, but the fourth attempts dies in a segfault. This behaviour is only apparent when I’m running on linux and launching via steam - when launched directly or on windows everything works as expected.
I’ve narrowed the behaviour down to this minimal example (I’m accessing GLFW via LWJGL):
public static void main(String[] args) {
LOG.info("Exercising segfault recreation!");
if (!glfwInit()) {
throw new IllegalStateException("Unable to initialize GLFW");
}
long window = createWindow();
for (int i = 0; i < 10; i++) {
LOG.info("iteration {}", i);
try {
Thread.sleep(100); // allowing logging to flush
} catch (InterruptedException ie) {
LOG.warn("unexpected!", ie);
}
glfwDestroyWindow(window);
window = createWindow();
glfwPollEvents();
glfwSwapBuffers(window);
}
LOG.info("normal exit");
}
private static long createWindow() {
long window = glfwCreateWindow(640, 480, "title", NULL, NULL);
glfwShowWindow(window);
return window;
}
The segfault occurs on the fourth iteration, in the glfwSwapBuffers call
Curiously, if the call to glfwPollEvents is commented out in the above, then no segfault occurs and it completes normally.
The only-when-launched-from-steam bit strongly suggests some bad interaction with steam’s overlay system, but I thought I’d better check I’m not doing something stupid before raising that support request. So the questions are:
- Does that sequence of calls look problematic?
- Has anyone seen this sort of thing before?
Cheers!