LWJGL Forum

Archive => Resolved Bugs/RFE => Topic started by: RoyAwesome on August 13, 2012, 06:10:30

Title: [CLOSED] glEnableVertexAttribArray twice with the same pointer crashes jvm
Post by: RoyAwesome on August 13, 2012, 06:10:30
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
Title: Re: [BUG] glEnableVertexAttribArray twice with the same pointer crashes jvm
Post by: princec on August 13, 2012, 08:34:32
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 :)
Title: Re: [BUG] glEnableVertexAttribArray twice with the same pointer crashes jvm
Post by: RoyAwesome on August 14, 2012, 02:24:01
http://pastebin.com/BpMmVi78

Relevent lines:



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
Title: Re: [BUG] glEnableVertexAttribArray twice with the same pointer crashes jvm
Post by: ra4king on August 14, 2012, 02:42:29
Could you paste relevant code please?
Title: Re: [BUG] glEnableVertexAttribArray twice with the same pointer crashes jvm
Post by: RoyAwesome on August 14, 2012, 03:18:34
I've since fixed it, but it was along the lines of




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.