# Segfault on window recreation, launching via steam, on linux

**URL:** <https://discourse.glfw.org/t/segfault-on-window-recreation-launching-via-steam-on-linux/2972>\
**Category:** support\
**Created:** [October 22, 2025, 8:02pm UTC](https://discourse.glfw.org/t/segfault-on-window-recreation-launching-via-steam-on-linux/2972 "2025-10-22T20:02:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![therealryan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/therealryan/32/1052_2.png) [@therealryan](https://discourse.glfw.org/u/therealryan)\
**Post date:** [October 22, 2025, 8:02pm UTC](https://discourse.glfw.org/t/segfault-on-window-recreation-launching-via-steam-on-linux/2972/1 "2025-10-22T20:02:27Z")

</div>

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):

```auto
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!

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [October 22, 2025, 8:15pm UTC](https://discourse.glfw.org/t/segfault-on-window-recreation-launching-via-steam-on-linux/2972/2 "2025-10-22T20:15:30Z")

</div>

Can you try same sequence of calls in C/C++ program directly with glfw native api? Because if that will not crash the same way, then it could mean problem is with lwjgl, not glfw.
