I'm using Java 8 and LWJGL to make a game engine with GLFW and OpenGL. I have a generic IndexedVAO class with all my VAO code in it to simplify things. Here are the relevant parts:
Constructor
GL30.glBindVertexArray(vertexArrayObject);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferObject);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBufferObject);
for(VertexAttribPointer prr : format.parts) {
GL20.glEnableVertexAttribArray(prr.index);
GL20.glVertexAttribPointer(prr.index, prr.size, prr.type,
prr.normalized, prr.stride, prr.ptr);
}
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL30.glBindVertexArray(0);
Upload Function
data.flip();
index.flip();
this.numberOfIndicies = index.limit() / 2;
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferObject);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, bufferUse);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBufferObject);
GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, index, bufferUse);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
Draw Function
GL30.glBindVertexArray(vertexArrayObject);
GL11.glDrawElements(this.drawmode, this.numberOfIndicies, GL11.GL_UNSIGNED_SHORT, 0L);
GL30.glBindVertexArray(0);
The code works fine on linux, but today I tried it on a windows machine and got an EXCEPTION_ACCESS_VIOLATION jvm crash. When I checked the hs_err_pid#### file the JVM generates when it crashes I figured out the error was caused by a call to glDrawElements. It was the first glDrawElements call in the whole application, and commenting it out just moved the exception to the next one. I spent my whole afternoon moving code around and doing research and I got nowhere. It's not shader-related, glDrawArrays works in it's place, and considering it works fine on linux means it has nothing to do with any of the vertex generation code because it's all the same java code.
One major hardware difference between the two machines is that the windows machine has an older radeon graphics card and the linux machine has a recent geforce card in it, both have the latest drivers. I booted linux on the radeon machine to see if it was an inconsistency between vendors but when I finished waiting 30 minutes for java to install everything worked fine, which means this is OS specific. To verify I had my friend test it on his windows 10 machine and he also got the EXCEPTION_ACCESS_VIOLATION.
TL; DR: the above code works on linux but on windows it causes an EXCEPTION_ACCESS_VIOLATION jvm crash
Thanks @derhass and @Spektre, the problem was that AMD's windows drivers couldn't properly handle vertex components that weren't aligned on 4-byte boundaries, so using bytes to store normals or rgb colors crashes the driver because the component was only three bytes long. Weird though, how it would work on linux even though it's the same card reading the vertex data.