Another problem with glDrawElements ()

I’m getting a random (1 in 20 or less) VM crash in glDrawElements (). I do not believe this is the same problem as mentionned in the sticky thread as I had it with the old 1.1.1 JOGL as well.

Here’s the dump I get:


#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x3d384a41, pid=2892, tid=1996
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_02-b09 mixed mode, sharing)
# Problematic frame:
# C  0x3d384a41
#

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

Current thread (0x0310e3b0):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=1996]

siginfo: ExceptionCode=0xc0000005, reading address 0x02f8e000

Registers:
EAX=0x3da9ea24, EBX=0x036a00c0, ECX=0x00002400, EDX=0x03200004
ESP=0x0361f2e0, EBP=0xbf800000, ESI=0x02f8e000, EDI=0x00000000
EIP=0x3d384a41, EFLAGS=0x00210202

Top of Stack: (sp=0x0361f2e0)
0x0361f2e0:   0000003f 036a00c0 00000008 00000675
0x0361f2f0:   3d0a8a42 036a00c0 3da9e7e0 031fffb8
0x0361f300:   032000b4 031f7000 00000004 00002aa2
0x0361f310:   0000003f 3d3849d0 3d0a939b 031fffb8
0x0361f320:   00000000 00000004 00001405 036a00c0
0x0361f330:   031f7000 00002aa2 3ceabf9e 3d920c80
0x0361f340:   00000004 00000000 ffffffff 00002aa2
0x0361f350:   00001405 031f7000 0361f380 0310e3b0 

Instructions: (pc=0x3d384a41)
0x3d384a31:   10 8b 7e 08 89 78 14 8b 35 cc 65 6a 03 8d 34 ce
0x3d384a41:   8b 3e 8b 6e 04 89 78 18 89 68 1c 83 c0 20 3b 54 


Stack: [0x035e0000,0x03620000),  sp=0x0361f2e0,  free space=252k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  0x3d384a41

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

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J  com.sun.opengl.impl.GLImpl.glDrawElements0(IIILjava/lang/Object;I)V
J  com.sun.opengl.impl.GLImpl.glDrawElements(IIILjava/nio/Buffer;)V
J  fuze3d.geometry.GeometryBuffer.draw(Ljavax/media/opengl/GL;I)V
J  fuze3d.animation.ms3d.MS3DModel$MaterialShader.draw(Lfuze3d/scenegraph/SceneView;Lfuze3d/geometry/Geometry;)V
J  fuze3d.scenegraph.Shape3D.renderObject(Lfuze3d/scenegraph/SceneView;)V
J  fuze3d.scenegraph.SceneObject.render(Lfuze3d/scenegraph/SceneView;)V
J  fuze3d.scenegraph.SceneObject.display(Lfuze3d/scenegraph/SceneView;)V
J  fuze3d.scenegraph.Group.display(Lfuze3d/scenegraph/SceneView;)V
J  fuze3d.scenegraph.Group.display(Lfuze3d/scenegraph/SceneView;)V
v  ~RuntimeStub::alignment_frame_return Runtime1 stub
j  fuze3d.scenegraph.ViewSpecificGroup.display(Lfuze3d/scenegraph/SceneView;)V+42
J  fuze3d.scenegraph.Group.display(Lfuze3d/scenegraph/SceneView;)V
J  fuze3d.scenegraph.Group.display(Lfuze3d/scenegraph/SceneView;)V
v  ~RuntimeStub::alignment_frame_return Runtime1 stub
j  fuze3d.scenegraph.SceneView.render()V+646
j  fuze3d.scenegraph.SceneCanvas.display(Ljavax/media/opengl/GLAutoDrawable;)V+56
j  com.sun.opengl.impl.GLDrawableHelper.display(Ljavax/media/opengl/GLAutoDrawable;)V+29
j  javax.media.opengl.GLCanvas$DisplayAction.run()V+80
j  com.sun.opengl.impl.GLDrawableHelper.invokeGL(Ljavax/media/opengl/GLDrawable;Ljavax/media/opengl/GLContext;Ljava/lang/Runnable;Ljava/lang/Runnable;)V+132
j  javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run()V+35
j  java.awt.event.InvocationEvent.dispatch()V+11
j  java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+26
j  java.awt.EventDispatchThread.pumpOneEventForHierarchy(ILjava/awt/Component;)Z+200
j  java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+26
j  java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
j  java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
j  java.awt.EventDispatchThread.run()V+9
v  ~StubRoutines::call_stub

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

Java Threads: ( => current thread )
  0x033ace30 JavaThread "Java Sound Event Dispatcher" daemon [_thread_blocked, id=3368]
  0x0306bf58 JavaThread "TimerQueue" daemon [_thread_blocked, id=3008]
  0x031b5008 JavaThread "Thread-3" [_thread_blocked, id=2872]
  0x009f3b00 JavaThread "Timer-0" daemon [_thread_blocked, id=3296]
  0x02fbe760 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=1036]
  0x00237fe8 JavaThread "DestroyJavaVM" [_thread_blocked, id=2880]
=>0x0310e3b0 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=1996]
  0x03099d10 JavaThread "AWT-Shutdown" [_thread_blocked, id=3072]
  0x030a5b38 JavaThread "AWT-Windows" daemon [_thread_in_native, id=1908]
  0x0099ed58 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3232]
  0x0099d908 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3224]
  0x0099cbc8 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2316]
  0x0099adb8 JavaThread "Finalizer" daemon [_thread_blocked, id=2896]
  0x009998a0 JavaThread "Reference Handler" daemon [_thread_blocked, id=2576]

Other Threads:
  0x00997018 VMThread [id=1984]
  0x009a02f0 WatcherThread [id=2476]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 10240K, used 7130K [0x16aa0000, 0x175b0000, 0x17e50000)
  eden space 9152K,  74% used [0x16aa0000, 0x17143b38, 0x17390000)
  from space 1088K,  30% used [0x174a0000, 0x174f2de0, 0x175b0000)
  to   space 1088K,   0% used [0x17390000, 0x17390000, 0x174a0000)
 tenured generation   total 135544K, used 115850K [0x17e50000, 0x202ae000, 0x26aa0000)
   the space 135544K,  85% used [0x17e50000, 0x1ef729e8, 0x1ef72a00, 0x202ae000)
 compacting perm gen  total 8192K, used 7323K [0x26aa0000, 0x272a0000, 0x2aaa0000)
   the space 8192K,  89% used [0x26aa0000, 0x271c6df8, 0x271c6e00, 0x272a0000)
    ro space 8192K,  66% used [0x2aaa0000, 0x2aff88a8, 0x2aff8a00, 0x2b2a0000)
    rw space 12288K,  46% used [0x2b2a0000, 0x2b834818, 0x2b834a00, 0x2bea0000)

Any suggestions for how I might attack this? I’ve tried most things I can think of and got nowhere so far…

Add some error checking code just before your call to glDrawElements to make sure everything is set up as you expect. Throw an exception if not, and then track down why the Buffer or other data is not in the state you expect.

Make sure your Buffers are rewound.

Hmmm. I’ve set my GLCanvas to use DebugGL - not a squeak. As far as I can tell, all is good before the call to glDrawElements. But I’m still getting this periodic crash. More often than not it’s in select mode when that happens but not always. (It feels like it always crashes after a mouse click, but not sure.)

Any further suggestions for tracking this down?

The DebugGL will not catch this kind of error as it looks like you’re walking off the end of a piece of memory. You should walk down the element array and make sure all of the indices are within the bounds of the vertex, color and other arrays you’re previously set up.

Hi,

Something else you may want to look at is make sure you are disabling client states that are not applicable to the geometry you are currently rendering.

For example, if your previously rendered model used a normal array and your current one doesn’t and this is not disabled with glDisableClientState(GL.GL_NORMAL_ARRAY) then you will have this problem if the previous model had fewer vertices.

I have been battling with the same issue for about a month. It was intermittent because only occasionally would the smaller model get rendered before the bigger one.

Hope this helps.