glDrawArrays() causes JVM to crash

Hi, I’m using LWJGL. I’m trying to draw 2D shadows using vertex arrays.

//This is the maximum number of shadow vertices there could possibly be. There probably won't be this many.
FloatBuffer shadows = BufferUtils.createFloatBuffer(2 * 4 * 3 * map.entities.size());
//2 coordinates x 4 per shadow quad x 3 (max) shadows per entity x number of entities

I calculate the shadows for each entity and add them to the buffer

shadows.put(new float[] {
		vertex.getX(), vertex.getY(),
		p1.getX(), p1.getY(),
		p2.getX(), p2.getY(),
		nextVertex.getX(), nextVertex.getY()
});

This is where I actually render the shadows.

glDisableClientState(GL_COLOR_ARRAY);
shadows.flip();
glVertexPointer(2, 0, shadows);

glDrawArrays(GL_QUADS, 0, shadows.remaining()); //This is the line that causes the crash

glEnableClientState(GL_COLOR_ARRAY);

I disable GL_COLOR_ARRAY because there is no color data for the vertices. I don’t know if it makes a difference, but I am rendering to the stencil buffer. This shouldn’t be an issue because I can do this correctly in immediate mode.

Here’s the JVM error that I receive:

http://pastebin.java-gaming.org/069d4348b76

Additionally, the shadows seemingly randomly glitch out for a few seconds then return back to normal. The glitching looks like this:

http://puu.sh/632wI.jpg

It should look like this:

http://puu.sh/632z0.jpg

I can confirm that the math is correct, as this all works flawlessly using immediate mode.

I cannot reliably make it crash. It always crashes, but it does so at seemingly random times. Sometimes it only works for 1 second, sometimes a whole minute.

I have no idea what is happening or what I am doing wrong. Any ideas?