Low-level exception when dealing with Fullscreen

When I start up my game, there’s about a 30% chance it abruptly crashes. I see a white full screen window at 640x480, then it just exits with this error:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d0b5f87, pid=2288, tid=2296
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0-b64 mixed mode, sharing)
# Problematic frame:
# C  [awt.dll+0xb5f87]
#

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

Current thread (0x00035de0):  JavaThread "main" [_thread_in_native, id=2296]

siginfo: ExceptionCode=0xc0000005, reading address 0x017afe65

Registers:
EAX=0x0007f8a4, EBX=0x00000001, ECX=0x017afe65, EDX=0x0007f928
ESP=0x0007f890, EBP=0x0007f978, ESI=0x0ae04540, EDI=0x0007f928
EIP=0x6d0b5f87, EFLAGS=0x00010246

Top of Stack: (sp=0x0007f890)
0x0007f890:   01000400 0007f8a4 00035e9c 0007f99c
0x0007f8a0:   2b394928 00000064 00035e9c 0007f99c
0x0007f8b0:   00000062 00035e9c 00035e9c 0007f99c
0x0007f8c0:   0007f8b4 00035e9c 0007fbb8 6d759f8a
0x0007f8d0:   6d764a90 ffffffff 0007f978 6d03423c
0x0007f8e0:   00035e9c 0007f99c 00000062 00035e9c
0x0007f8f0:   0007f99c ff000000 6d0342b7 00035e9c
0x0007f900:   0007f99c 00000000 6d0af2d6 00035e9c 

Instructions: (pc=0x6d0b5f87)
0x6d0b5f77:   8b 8e a8 00 00 00 8d 44 24 0c 50 68 00 04 00 01
0x6d0b5f87:   8b 11 6a 00 6a 00 57 ff 52 20 3d c2 01 76 88 7f 


Stack: [0x00040000,0x00080000),  sp=0x0007f890,  free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [awt.dll+0xb5f87]
j  sun.awt.windows.Win32DDRenderer.fillRect(Lsun/java2d/SunGraphics2D;IIII)V+146
j  sun.java2d.pipe.ValidatePipe.fillRect(Lsun/java2d/SunGraphics2D;IIII)V+19
j  sun.java2d.SunGraphics2D.fillRect(IIII)V+10
j  scepter.engine.graphics.Surface.clear()V+22
j  scepter.engine.GameEngine.start()V+81
j  scepter.Scepter.main([Ljava/lang/String;)V+3
v  ~StubRoutines::call_stub
V  [jvm.dll+0x8168d]
V  [jvm.dll+0xd4179]
V  [jvm.dll+0x8155e]
V  [jvm.dll+0x8844c]
C  [java.exe+0x14c0]
C  [java.exe+0x64cd]
C  [kernel32.dll+0x2141a]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  sun.awt.windows.Win32DDRenderer.doFillRectDD(Lsun/java2d/SurfaceData;IIIII)V+0
j  sun.awt.windows.Win32DDRenderer.fillRect(Lsun/java2d/SunGraphics2D;IIII)V+146
j  sun.java2d.pipe.ValidatePipe.fillRect(Lsun/java2d/SunGraphics2D;IIII)V+19
j  sun.java2d.SunGraphics2D.fillRect(IIII)V+10
j  scepter.engine.graphics.Surface.clear()V+22
j  scepter.engine.GameEngine.start()V+81
j  scepter.Scepter.main([Ljava/lang/String;)V+3
v  ~StubRoutines::call_stub

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

Java Threads: ( => current thread )
  0x0ae02150 JavaThread "Direct Clip" daemon [_thread_blocked, id=3588]
  0x0ae01cd0 JavaThread "Direct Clip" daemon [_thread_blocked, id=3332]
  0x00acfde0 JavaThread "Java Sound Sequencer" [_thread_blocked, id=3484]
  0x0add49b0 JavaThread "Headspace mixer frame proc thread" daemon [_thread_blocked, id=2216]
  0x00accab8 JavaThread "Java Sound Event Dispatcher" daemon [_thread_blocked, id=1652]
  0x00acc7f8 JavaThread "Java Sound Event Dispatcher" daemon [_thread_blocked, id=2940]
  0x00ac0d88 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=3700]
  0x00abbd60 JavaThread "AWT-Windows" daemon [_thread_in_native, id=2924]
  0x00abb930 JavaThread "AWT-Shutdown" [_thread_blocked, id=956]
  0x00aba6c0 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=1604]
  0x00a6bc80 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3220]
  0x00a6a858 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2872]
  0x00a69b00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=800]
  0x00a45ee0 JavaThread "Finalizer" daemon [_thread_blocked, id=2852]
  0x0003fa00 JavaThread "Reference Handler" daemon [_thread_blocked, id=492]
=>0x00035de0 JavaThread "main" [_thread_in_native, id=2296]

Other Threads:
  0x00a67150 VMThread [id=2380]
  0x00a6ce90 WatcherThread [id=2408]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 576K, used 6K [0x22a60000, 0x22b00000, 0x22f40000)
  eden space 512K,   1% used [0x22a60000, 0x22a61880, 0x22ae0000)
  from space 64K,   0% used [0x22ae0000, 0x22ae0000, 0x22af0000)
  to   space 64K,   0% used [0x22af0000, 0x22af0000, 0x22b00000)
 tenured generation   total 4612K, used 3967K [0x22f40000, 0x233c1000, 0x26a60000)
   the space 4612K,  86% used [0x22f40000, 0x2331fc58, 0x2331fe00, 0x233c1000)
 compacting perm gen  total 8192K, used 719K [0x26a60000, 0x27260000, 0x2aa60000)
   the space 8192K,   8% used [0x26a60000, 0x26b13f28, 0x26b14000, 0x27260000)
    ro space 8192K,  66% used [0x2aa60000, 0x2afb7960, 0x2afb7a00, 0x2b260000)
    rw space 12288K,  46% used [0x2b260000, 0x2b7f43a8, 0x2b7f4400, 0x2be60000)

Dynamic libraries:
0x00400000 - 0x0040c000       C:\Program Files\Java\jdk1.5.0\bin\java.exe
0x77f50000 - 0x77ff7000       C:\WINDOWS\System32\ntdll.dll
0x77e60000 - 0x77f46000       C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e5d000       C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x78087000       C:\WINDOWS\system32\RPCRT4.dll
0x77c10000 - 0x77c63000       C:\WINDOWS\system32\MSVCRT.dll
0x6d640000 - 0x6d7c5000       C:\Program Files\Java\jdk1.5.0\jre\bin\client\jvm.dll
0x77d40000 - 0x77dcc000       C:\WINDOWS\system32\USER32.dll
0x7f000000 - 0x7f041000       C:\WINDOWS\system32\GDI32.dll
0x76b40000 - 0x76b6c000       C:\WINDOWS\System32\WINMM.dll
0x6d280000 - 0x6d288000       C:\Program Files\Java\jdk1.5.0\jre\bin\hpi.dll
0x76bf0000 - 0x76bfb000       C:\WINDOWS\System32\PSAPI.DLL
0x6d610000 - 0x6d61c000       C:\Program Files\Java\jdk1.5.0\jre\bin\verify.dll
0x6d300000 - 0x6d31d000       C:\Program Files\Java\jdk1.5.0\jre\bin\java.dll
0x6d630000 - 0x6d63f000       C:\Program Files\Java\jdk1.5.0\jre\bin\zip.dll
0x6d000000 - 0x6d166000       C:\Program Files\Java\jdk1.5.0\jre\bin\awt.dll
0x73000000 - 0x73023000       C:\WINDOWS\System32\WINSPOOL.DRV
0x76390000 - 0x763ac000       C:\WINDOWS\System32\IMM32.dll
0x771b0000 - 0x772d4000       C:\WINDOWS\system32\ole32.dll
0x5ad70000 - 0x5ada4000       C:\WINDOWS\System32\uxtheme.dll
0x51000000 - 0x51049000       C:\WINDOWS\System32\ddraw.dll
0x73bc0000 - 0x73bc6000       C:\WINDOWS\System32\DCIMAN32.dll
0x5c000000 - 0x5c0c8000       C:\WINDOWS\System32\D3DIM700.DLL
0x6d240000 - 0x6d27d000       C:\Program Files\Java\jdk1.5.0\jre\bin\fontmanager.dll
0x10000000 - 0x10007000       C:\Program Files\Logitech\MouseWare\System\LgWndHk.dll
0x02dc0000 - 0x02dcb000       C:\Program Files\Common Files\Logitech\Scrolling\LgMsgHk.dll
0x55900000 - 0x55961000       C:\WINDOWS\System32\MSVCP60.dll
0x6d190000 - 0x6d1bf000       C:\Program Files\Java\jdk1.5.0\jre\bin\cmm.dll
0x6d3c0000 - 0x6d3df000       C:\Program Files\Java\jdk1.5.0\jre\bin\jpeg.dll
0x6d470000 - 0x6d495000       C:\Program Files\Java\jdk1.5.0\jre\bin\jsound.dll
0x6d4a0000 - 0x6d4a7000       C:\Program Files\Java\jdk1.5.0\jre\bin\jsoundds.dll
0x51080000 - 0x510dd000       C:\WINDOWS\System32\DSOUND.dll
0x77c00000 - 0x77c07000       C:\WINDOWS\system32\VERSION.dll
0x72d20000 - 0x72d29000       C:\WINDOWS\System32\wdmaud.drv
0x72d10000 - 0x72d18000       C:\WINDOWS\System32\msacm32.drv
0x77be0000 - 0x77bf4000       C:\WINDOWS\System32\MSACM32.dll
0x77bd0000 - 0x77bd7000       C:\WINDOWS\System32\midimap.dll
0x5ef80000 - 0x5ef84000       C:\WINDOWS\System32\KsUser.dll

VM Arguments:
java_command: scepter.Scepter

Environment Variables:
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\MinGW\bin;C:\Program Files\Java\jdk1.5.0\bin
USERNAME=Jason
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 10 Stepping 0, AuthenticAMD


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

OS: Windows XP Build 2600 Service Pack 1

CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse

Memory: 4k page, physical 523764k(174940k free), swap 1280332k(974092k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0-b64) for windows-x86, built on Sep 15 2004 03:00:31 by "java_re" with MS VC++ 6.0


This only occurs in fullscreen mode and not windowed. It crashes at the first drawing function I attempt to call, which is simply g.fillRect(0, 0, 640, 480);

The problem code is a simplified version this:

frame.createBufferStrategy(2);
// then call getDrawGraphics() and use this to call fillRect

Adding a sleep() between those two statements seems to fix everything. Even a Thread.sleep(0).

I’ve heard of similar things happening to people before, but this is the first time it’s happened to me. Is my “solution” the only option I have? Is this a known bug, because I thought it was fixed by 1.5? I don’t know, maybe it’s my code afterall, I just don’t see it.

Anyway, thanks for any explanations.

Since its a native crash is likely to do with the particular version of the JVM you’re using. I note there’s still a “b64” on your version. I think thats beta?

Is there a newer version out yet?

Kev

[quote]Since its a native crash is likely to do with the particular version of the JVM you’re using. I note there’s still a “b64” on your version. I think thats beta?

Is there a newer version out yet?

Kev
[/quote]
“b” numbers are supposed to be no longer in usage. It was a bug that they continued to be used in linux for a while for the actual normal releases(1.4.2-b29 IIRC being the last one before they fixed it, and switched to the numbering scheme that Sun has officially declared (the _03, _04, _05 etc scheme). I believe it was b for build, not beta, since the numbers are far too high to mean anything else.

So, it could well be that the bug they thought they’d fixed has come back again :). Youll need to “java -version” to find out.

Anyway, current version of java 5 is 1.5.0_01. If you have anything else, you are behind, and you should upgrade immediately.

I actually didn’t have the latest release, but I just got it and the problem is still there. It’s the same error message but the version now shows up as 1.5.0_01-b08

I woudl guess this is one of those major bugs in java 5 we all just expected because its a “.0” release - contrary to the public protestations of Sun executives telling us we were silly and that java 5 was as stable or more stable than mature java releases :P.

So…check if it works in 1.4.2_06, then log a bug report (google: sun java bug report). If it works in 1.4.2 it’s more likely you’ll get a quick fix, I suspect, since regression bugs are easier to fix. If it doesn’t work in 1.4.2 either, then probably you have some underlying hardware / graphics driver / etc problem that they’re still working on - but would appreciate you logging the bug anyway.

Then again…seeing as you’re using an out of date :stuck_out_tongue: copy of windows (SP1) perhaps you’re the kind of person using old graphics drivers too? ::slight_smile:

I guess the only thing left to do is to file a bug report. Thanks.

[quote]Then again…seeing as you’re using an out of date :stuck_out_tongue: copy of windows (SP1) perhaps you’re the kind of person using old graphics drivers too? ::slight_smile:
[/quote]
Service Pack 2 seems to be crap from what I’ve heard. :frowning: That’s why I haven’t upgraded yet.

I think I may have found out why my code crashed all the time. I ran some other fullscreen programs, and they ran just fine. So I tested my app further to see what the problem was.

I was creating a class called “Surface” and right after I called createBufferStrategy(2), I saved a reference of the Graphics object in the Surface class. Constructing it like:
Surface screen = new Surface(bufferStrategy.getDrawGraphics());
Then I would use “screen” to do all my drawing.

I now changed my code to call getDrawGraphics() every loop, and after I’m done using the Graphics object for one loop, I dispose of it. My program hasn’t crashed yet, so this may have fixed the problem.

Does this make sense to anybody? I’m wondering what the difference is. Well, now I have to make quite a few design changes because of this… but as long as it’s working now, I’m happy :slight_smile:

FYI: the ‘b’ in the java string name stands for ‘build’ - in case that’s not obvious.

As for the crash, please file a bug, including a test case, information about the configuration (os, video board, drivers version, directx version).

As for the workaround: caching a graphics object is not a good idea in general…

Ok, I just submitted the bug report.

Thanks, I had it assigned to me on Friday =)