JVM reporting error when using LWJGL

Started by Cubic, April 07, 2012, 18:09:29

Previous topic - Next topic

Cubic

I am getting the following error message when running a simple LWJGL test program:

Quote#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fd3173bfc08, pid=2661, tid=140544831526688
#
# JRE version: 7.0_147-b147
# Java VM: OpenJDK 64-Bit Server VM (21.0-b17 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea7 2.0
# Distribution: Ubuntu 11.10, package 7~b147-2.0-0ubuntu0.11.10.1
# Problematic frame:
# C  [libX11.so.6+0x35c08]  XQueryExtension+0x28
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/hannes/git/LWJGLTest/LWJGL/hs_err_pid2661.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   https://bugs.launchpad.net/ubuntu/+source/openjdk-7/
#

Here's the code:

import java.util.Scanner;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.ContextAttribs;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.PixelFormat;

public class LWJGLTest {
	public static void main(String[] args) {
		try {
			Scanner scanner = new Scanner(System.in);
			for (DisplayMode mode : Display.getAvailableDisplayModes()) {
				System.out.println(mode + " Do you want this mode?[y/n]");
				String line;
				do {
					line = scanner.nextLine();
				}while(!line.matches("([yn])|(yes)|(no)"));
				if(line.startsWith("y")) {
					Display.setDisplayModeAndFullscreen(mode);
					break;
				}
			}
			if(!Display.isFullscreen()) {
				throw new RuntimeException("No display mode selected!");
			}
			Display.create(new PixelFormat(), new ContextAttribs(3,3)
			                                  .withProfileCore(true)
			                                  .withForwardCompatible(true));
			Display.sync(60);
			GL11.glClearColor(1.0f, 0.6f, 0.0f, 1.0f);
			boolean running = true;
			while(running && !Display.isCloseRequested()) {
				while(Keyboard.next()) {
					if(Keyboard.getEventKeyState()) {
						if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
							running = false;
						}
					}
				}
				GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
				Display.update();
			}
			
		} catch (LWJGLException e) {
			e.printStackTrace();
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
	}
}
(I really just wanted to check if my setup was working, so this looks a bit ugly. Sorry)

Am I doing something wrong, or is this a bug?

Epicbo

I tried running your program and worked fine. I've no idea why it isn't working for you. Sorry I can't help you :/

Cubic

Well, it's running for me to - I only get the error once the program terminates. It seems to be a problem with the native calls to Xlib, so if you aren't using Linux you won't get this error.

matheus23

I remeber, I had that problem too, but I don't know how I fixed it, and why that was... Also, I can't reproduce it anymore...
The only thing that *might* help, is: call Display.destroy() at the end? maybe?
My github account and currently active project: https://github.com/matheus23/UniverseEngine

Cubic

It's not Display.destroy() - I already tried that in exactly that program.