Hello Guest

Crash during WindowsContextImplementation.nSwapBuffers when using FBO

  • 1 Replies
I'm using Slick2D (yeah, I know, outdated library) with lwjgl 2.9.3. On some machines only, if using a fullscreen display, I get an EXCEPTION_ACCESS_VIOLATION from WindowsContextImplementation.nSwapBuffers if I used an FBO-based "Graphics" object.


The Slick2D code that causes this:
Code: [Select]
Image img = new Image(128, 128);

What it does in the background:

(See linked code for details.)

Somehow, in this process, it messes up some state, which later causes the following crash:

Code: [Select]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.lwjgl.opengl.WindowsContextImplementation.nSwapBuffers(Ljava/nio/ByteBuffer;)V+0
j org.lwjgl.opengl.WindowsContextImplementation.swapBuffers()V+35
j org.lwjgl.opengl.ContextGL.swapBuffers()V+3
j org.lwjgl.opengl.DrawableGL.swapBuffers()V+0
j org.lwjgl.opengl.Display.swapBuffers()V+39
j org.lwjgl.opengl.Display.update(Z)V+44
j org.lwjgl.opengl.Display.update()V+1

I've been digging through the code, but I don't know how the FBO stuff is supposed to work, and what it might be doing wrong. I can reliably reproduce it one one machine using the following Slick2D code:

Code: [Select]
package crashrepro;

import org.newdawn.slick.*;

public class CrashRepro extends BasicGame {
    public static void main(String[] args) throws Exception {
        CrashRepro cr = new CrashRepro("CrashRepro");
        // Crash only happens in fullscreen mode, and only on some machines.
        AppGameContainer agc = new AppGameContainer(cr, 800, 600, true);

    public CrashRepro(String title) { super(title); }

    public void init(GameContainer gc) throws SlickException {}

    public void update(GameContainer gc, int i) throws SlickException {}

    Image img;

    public void render(GameContainer gc, Graphics grphcs) throws SlickException {
        if (img == null) { img = new Image(128, 128); }
        img.getGraphics(); // This causes a crash in the next nSwapBuffers call.

Any advice, or ideas where to start digging/diagnosing this further?

OK, this turned out to be caused by a lwjgl bug I've reported here.