Hello Guest

[CLOSED] glEnableVertexAttribArray twice with the same pointer crashes jvm

  • 4 Replies
  • 11079 Views
So, I got this pretty well reproducible.

If you call glEnableVertexAttribArray twice with the same pointer, the jvm will crash in glDrawArrays


I know such a problem is the programmer being stupid, but it would be nice if there was some sanity checking here to tell you exactly what the problem is.


EDIT: After further investigation, this may be a driver issue.  I'll see if I can repro in C code
« Last Edit: August 13, 2012, 06:26:25 by RoyAwesome »

*

Offline princec

  • *****
  • 1933
    • Puppygames
If it crashes the JVM in a different native method, it's almost certainly a driver bug, but post the Hotspot crash dump anyway.

Cas :)

http://pastebin.com/BpMmVi78

Relevent lines:

Code: [Select]

Stack: [0x00000000097c0000,0x00000000098c0000],  sp=0x00000000098bf138,  free space=1020k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [nvoglv64.DLL+0x791d40]

[error occurred during error reporting (printing native stack), id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.opengl.GL11.nglDrawArrays(IIIJ)V+0
j  org.lwjgl.opengl.GL11.glDrawArrays(III)V+20
j  org.spout.engine.renderer.GL30BatchVertexRenderer.doRender()V+115
j  org.spout.engine.renderer.BatchVertexRenderer.render()V+22
j  org.spout.engine.batcher.PrimitiveBatch.draw()V+4
j  org.spout.engine.SpoutClient.render(F)V+48
j  org.spout.engine.scheduler.SpoutScheduler$RenderThread.run()V+67
v  ~StubRoutines::call_stub

I haven't had a chance to test this in C, and I think i may be behind a driver update or two.  Let me do that before digging any deeper
« Last Edit: August 14, 2012, 02:25:53 by RoyAwesome »

*

Offline ra4king

  • **
  • 58
  • I'm the King!
    • Roi's Website
Could you paste relevant code please?
-Roi

I've since fixed it, but it was along the lines of

Code: [Select]


Shader.enableAttribute(int location, int size, int type, int stride, long offset){
  GL20.glEnableVertexAttribArray(location);
  GL20.glVertexAttribPointer(location, size, type, false, stride, offset);
}

----


foreach(VertexBuffer vb : vertexBuffers){
  GL15.glBindBuffer(vb.getID());
  GL20.glEnableVertexAttribArray(vb.getLocation());
  shader.enableAttribute(vb.getLocation, vb.getElementCount(), GL11.GL_FLOAT, 0, 0);

}

GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, numVerticies);

I had forgotten I called glEnableVertexAttribArray in my shader class, so I managed call it twice in a row before calling glDrawArrays.  It's clearly programmer error, but it did cause a jvm crash.  I managed to miss the nvogl call in the crash dump originally, so I thought it was a lwjgl problem, but this is clearly not. 
« Last Edit: August 14, 2012, 03:20:19 by RoyAwesome »