Display.destroy() crashes...and i'm out of ideas

Started by EgonOlsen, August 29, 2007, 18:35:40

Previous topic - Next topic

EgonOlsen

Hi!

On Windows XP when using Nvidia cards (6800GT, 7600GT, 7800GS...just pick one), i'm getting segmentation faults when calling Display.destroy(). I would like to create a test case, but unfortunately i can't, because it seems to be impossible to isolate the problem. I have complex application that don't crash while others (simpler ones) do. When adding some pointless code to the simpler ones (like doing some bogus viewport adjustment or whatever), the crashes go away...sometimes...to make it short: I don't get it. I tried to unload all the textures before exiting and making OpenGL's state as "clean" as possible but to no avail.
Here's a dump (the dir says lwjgl-1.0 but actually it's 1.1.2...but 1.0 has the same problem):

#
# An unexpected error has been detected by Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6952ef04, pid=296, tid=416
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_02-b06 mixed mode, sharing)
# Problematic frame:
# C  [nvoglnt.dll+0x2ef04]
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

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

Current thread (0x00296000):  JavaThread "main" [_thread_in_native, id=416]

siginfo: ExceptionCode=0xc0000005, writing address 0x00000099

Registers:
EAX=0x00000041, EBX=0x03121dc0, ECX=0x69b15ccc, EDX=0x035cb200
ESP=0x0090f998, EBP=0x00000000, ESI=0x03132a80, EDI=0x0000000d
EIP=0x6952ef04, EFLAGS=0x00010206

Top of Stack: (sp=0x0090f998)
0x0090f998:   69632ea3 035cb200 00000041 00000003
0x0090f9a8:   035e380c 03121e24 03121dc0 69598d93
0x0090f9b8:   035cb200 03121dc0 03132a80 00000000
0x0090f9c8:   03625d00 00000000 035cb200 ffffffff
0x0090f9d8:   6966562c 035cb200 03121dc0 035e4efc
0x0090f9e8:   035cb200 0359ac00 00000000 69631301
0x0090f9f8:   035e470c 00000000 00000001 035cb200
0x0090fa08:   6973c52e 035cb200 e24f0740 035cb200 

Instructions: (pc=0x6952ef04)
0x6952eef4:   83 00 ff 50 ff 15 34 80 b1 69 59 c3 8b 44 24 08
0x6952ef04:   83 48 58 01 83 00 ff 75 09 89 44 24 08 e9 aa f3 


Stack: [0x008c0000,0x00910000),  sp=0x0090f998,  free space=318k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [nvoglnt.dll+0x2ef04]

[error occurred during error reporting, step 120, id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.opengl.WindowsContextImplementation.nDestroy(Ljava/nio/ByteBuffer;)V+0
j  org.lwjgl.opengl.WindowsContextImplementation.destroy(Lorg/lwjgl/opengl/PeerInfo;Ljava/nio/ByteBuffer;)V+1
j  org.lwjgl.opengl.Context.checkDestroy()V+29
j  org.lwjgl.opengl.Context.destroy()V+47
j  org.lwjgl.opengl.Context.forceDestroy()V+5
j  org.lwjgl.opengl.Display.destroyContext()V+3
j  org.lwjgl.opengl.Display.destroy()V+18
j  com.threed.jpct.GLHelper.dispose()V+18
j  com.threed.jpct.GLRenderer.dispose()V+4
j  com.threed.jpct.FrameBuffer.disableRenderer(I)V+63
j  Beethoven2.doIt()V+442
j  Beethoven2.main([Ljava/lang/String;)V+17
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x02f89800 JavaThread "AWT-Windows" daemon [_thread_in_native, id=308]
  0x02b14000 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=1964]
  0x02b1c800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1056]
  0x02b17800 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1880]
  0x02b16800 JavaThread "Attach Listener" daemon [_thread_blocked, id=668]
  0x02b15800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1916]
  0x02b11000 JavaThread "Finalizer" daemon [_thread_blocked, id=1824]
  0x02b0cc00 JavaThread "Reference Handler" daemon [_thread_blocked, id=1488]
=>0x00296000 JavaThread "main" [_thread_in_native, id=416]

Other Threads:
  0x02b03800 VMThread [id=1116]
  0x02b1dc00 WatcherThread [id=2004]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 5696K, used 5120K [0x16960000, 0x16f80000, 0x17d10000)
  eden space 5120K, 100% used [0x16960000, 0x16e60000, 0x16e60000)
  from space 576K,   0% used [0x16e60000, 0x16e60000, 0x16ef0000)
  to   space 576K,   0% used [0x16ef0000, 0x16ef0000, 0x16f80000)
 tenured generation   total 74864K, used 44916K [0x17d10000, 0x1c62c000, 0x26960000)
   the space 74864K,  59% used [0x17d10000, 0x1a8ed308, 0x1a8ed400, 0x1c62c000)
 compacting perm gen  total 12288K, used 1375K [0x26960000, 0x27560000, 0x2a960000)
   the space 12288K,  11% used [0x26960000, 0x26ab7d00, 0x26ab7e00, 0x27560000)
    ro space 8192K,  62% used [0x2a960000, 0x2ae5f728, 0x2ae5f800, 0x2b160000)
    rw space 12288K,  52% used [0x2b160000, 0x2b7a1eb8, 0x2b7a2000, 0x2bd60000)

Dynamic libraries:
0x00400000 - 0x00423000 	C:\WINDOWS\system32\java.exe
0x7c910000 - 0x7c9c7000 	C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c907000 	C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e4a000 	C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee1000 	C:\WINDOWS\system32\RPCRT4.dll
0x7c340000 - 0x7c396000 	C:\Programme\Java\jre1.6.0_02\bin\msvcr71.dll
0x6d7c0000 - 0x6da09000 	C:\Programme\Java\jre1.6.0_02\bin\client\jvm.dll
0x77d10000 - 0x77da0000 	C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f37000 	C:\WINDOWS\system32\GDI32.dll
0x76af0000 - 0x76b1e000 	C:\WINDOWS\system32\WINMM.dll
0x6d310000 - 0x6d318000 	C:\Programme\Java\jre1.6.0_02\bin\hpi.dll
0x76bb0000 - 0x76bbb000 	C:\WINDOWS\system32\PSAPI.DLL
0x6d770000 - 0x6d77c000 	C:\Programme\Java\jre1.6.0_02\bin\verify.dll
0x6d3b0000 - 0x6d3cf000 	C:\Programme\Java\jre1.6.0_02\bin\java.dll
0x6d7b0000 - 0x6d7bf000 	C:\Programme\Java\jre1.6.0_02\bin\zip.dll
0x6d000000 - 0x6d1c3000 	C:\Programme\Java\jre1.6.0_02\bin\awt.dll
0x72f70000 - 0x72f96000 	C:\WINDOWS\system32\WINSPOOL.DRV
0x77be0000 - 0x77c38000 	C:\WINDOWS\system32\msvcrt.dll
0x76330000 - 0x7634d000 	C:\WINDOWS\system32\IMM32.dll
0x774b0000 - 0x775ed000 	C:\WINDOWS\system32\ole32.dll
0x10000000 - 0x1004c000 	C:\Dokumente und Einstellungen\egonolsen\Desktop\jpctapi\crash\lib\lwjgl-1.0\lwjgl.dll
0x72210000 - 0x7223b000 	C:\WINDOWS\system32\DINPUT.dll
0x5f0d0000 - 0x5f19c000 	C:\WINDOWS\system32\OPENGL32.dll
0x68fc0000 - 0x68fe0000 	C:\WINDOWS\system32\GLU32.dll
0x736d0000 - 0x73719000 	C:\WINDOWS\system32\DDRAW.dll
0x73b30000 - 0x73b36000 	C:\WINDOWS\system32\DCIMAN32.dll
0x77bd0000 - 0x77bd8000 	C:\WINDOWS\system32\VERSION.dll
0x746a0000 - 0x746eb000 	C:\WINDOWS\system32\MSCTF.dll
0x69500000 - 0x69b7f000 	C:\WINDOWS\system32\nvoglnt.dll
0x6d450000 - 0x6d474000 	C:\Programme\Java\jre1.6.0_02\bin\jpeg.dll

VM Arguments:
jvm_args: -Dsun.java2d.noddraw=true -Djava.library.path=lib\lwjgl-1.0\ -Xmx256m
java_command: Beethoven2
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
USERNAME=egonolsen
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 55 Stepping 2, AuthenticAMD



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 2

CPU:total 1 (1 cores per cpu, 1 threads per core) family 15 model 55 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, mmxext, 3dnow, 3dnowext

Memory: 4k page, physical 1572340k(1185668k free), swap 2205520k(1942392k free)

vm_info: Java HotSpot(TM) Client VM (1.6.0_02-b06) for windows-x86, built on Jul 12 2007 01:16:14 by "java_re" with unknown MS VC++:1310


Any ideas? This machine is an Athlon64 4400+, Windows XP Home, Java 1.6, 7600GT PCIe, latest official drivers...but it happens on other machines too. It doesn't happen on ATI or Intel based graphic setups.

Edit: When skipping Display.destroy() and exiting via a simple System.exit(0);, there's no problem.

Matzon

QuoteJNIEXPORT void JNICALL Java_org_lwjgl_opengl_WindowsContextImplementation_nDestroy
  (JNIEnv *env, jclass clazz, jobject context_handle) {
   WindowsContext *context_info = (WindowsContext *)(*env)->GetDirectBufferAddress(env, context_handle);
   wglDeleteContext(context_info->context);
}
not a lot of things that could go wrong  ???

EgonOlsen

Quote from: Matzon on August 29, 2007, 22:04:20
not a lot of things that could go wrong  ???
But something does... :'( I tried to run it with various command line options. The best i could get out of it was this, but i don't think that it'll be very helpful:

....closing the window here and doing some cleanup work...
[Dynamic-linking native method org.lwjgl.opengl.WindowsContextImplementation.nIsCurrent ... JNI]
[Dynamic-linking native method org.lwjgl.opengl.GL11.nglDeleteTextures ... JNI]
[Dynamic-linking native method org.lwjgl.opengl.GL11.nglFinish ... JNI]
[Dynamic-linking native method org.lwjgl.opengl.WindowsContextImplementation.nReleaseCurrentContext ... JNI]
[Dynamic-linking native method org.lwjgl.opengl.WindowsDisplay.doDestroyCursor ... JNI]
[Dynamic-linking native method org.lwjgl.opengl.WindowsDisplay.nDestroyWindow ... JNI]
[Dynamic-linking native method org.lwjgl.opengl.WindowsContextImplementation.nDestroy ... JNI]
...BOOM...

elias

I'm afraid I don't know what is causing this, except guessing at an NVIDIA driver bug (heh). One thing to try is avoiding fullscreen mode switching, to minimize the amount of LWJGL code executing. In general, minimze the amount of native code (disable openal, devil, fmod etc.). Are you doing anything fancy, like using ogl from different threads?

- elias

EgonOlsen

Fullscreen/windowed makes no difference. No, i'm not doing anything fancy. I'm doing some simple initialization work and draw some triangles...even when using immediate mode only, it still crashes on some applications. OpenGL init code (as well as the rest of the engine's code) is always exactly the same. It's just that some apps crash, some don't.  :'(
If it's a driver bug, it's a very persistent one, because i'm experiencing this since...i don't know. But for quite some time now with various drivers. I guess that i'm doing something wrong, but i have no clue what that should be... ???