LWJGL Forum

Programming => Bug Reports / RFE => Topic started by: ryanm on October 21, 2025, 21:14:29

Title: Segfault, but only when running from steam and on linux
Post by: ryanm on October 21, 2025, 21:14:29
This is the most cornery of corner cases, but I'm experiencing a segfault that only happens when I run my game via steam, and on linux.
It can be reliably triggered by changing the display parameters that require me to tear down and recreate the window - you can do this with no issue up to three times, but the fourth will provoke a segfault.

I've cut things down to this minimal case:

  public static void main(String[] args) {
    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) {
      }
      GLFW.glfwDestroyWindow(window);
      window = createWindow();
      GLFW.glfwPollEvents();
      GLFW.glfwSwapBuffers(window);
    }
    LOG.info("normal exit");
  }

  private static long createWindow() {
    long window = glfwCreateWindow(640, 480, "title", NULL, NULL);
    glfwMakeContextCurrent(window);
    glfwShowWindow(window);
    return window;
  }

If I run that directly from the IDE, it completes normally. If I run it from steam (which presumably brings steam's overlay stuff into play), it'll segfault on the 4th iteration.

Interestingly, commenting out the GLFW.glfwPollEvents() call allows normal exit - no segfault is provoked.

I'd like to attach the hs_err_pid file, but that provokes an error from the forum. The summary of the dump is:
---------------  S U M M A R Y ------------

Command Line: -Djdk.module.main=dev.flowty.trace dev.flowty.trace/dev.flowty.trace.Main

Host: AMD Custom APU 0405, 8 cores, 14G, Steam Runtime 2 (soldier)
Time: Tue Oct 21 21:54:24 2025 IST elapsed time: 1.040722 seconds (0d 0h 0m 1s)

---------------  T H R E A D  ---------------

Current thread (0x00007fb63002c110):  JavaThread "main"             [_thread_in_native, id=31412, stack(0x00007fb637500000,0x00007fb637600000) (1024K)]

Stack: [0x00007fb637500000,0x00007fb637600000],  sp=0x00007fb6375f9bd0,  free space=998k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [gameoverlayrenderer.so+0x499b9]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.system.JNI.invokePV(JJ)V+0 org.lwjgl@3.3.6+1
j  org.lwjgl.glfw.GLFW.glfwSwapBuffers(J)V+17 org.lwjgl.glfw@3.3.6+1
j  dev.flowty.trace.Main.main([Ljava/lang/String;)V+65 dev.flowty.trace@0.0.1-SNAPSHOT
v  ~StubRoutines::call_stub 0x00007fb622537cc6


Can anyone spot what I'm doing wrong?

Cheers!