[Driver Bug] glEnableVertexAttribArray(4) crash

Hi! I want to enable a new vertex attrib array to pass the texture index to my shader but when I want to do it, the driver crash!

void RenderTarget::drawVertexBuffer(VertexBuffer& vertexBuffer, RenderStates states) {
        if (vertexBuffer.getVertexCount() == 0) {
            return;
        }

        if (activate(true))
        {

            if (!m_cache.glStatesSet)
                resetGLStates();
            // Apply the view
            if (m_cache.viewChanged)
                applyCurrentView();

            if (states.blendMode != m_cache.lastBlendMode)
                applyBlendMode(states.blendMode);

            // Apply the texture
            sf::Uint64 textureId = states.texture ? states.texture->getNativeHandle() : 0;
            if (textureId != m_cache.lastTextureId)
                applyTexture(states.texture);
            // Apply the shader
            if (states.shader)
                applyShader(states.shader);
            if (m_versionMajor > 3 || m_versionMajor == 3 && m_versionMinor >= 3)
                glCheck(glBindVertexArray(m_vao));
            if (m_cache.lastVboBuffer != &vertexBuffer) {
                if (m_versionMajor > 3 || m_versionMajor == 3 && m_versionMinor >= 3) {
                    glCheck(glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.vboVertexBuffer));
                    glCheck(glEnableVertexAttribArray(0));
                    glCheck(glEnableVertexAttribArray(1));
                    glCheck(glEnableVertexAttribArray(2));
                    glCheck(glVertexAttribPointer(0, 3,GL_FLOAT,GL_FALSE,sizeof(Vertex), (GLvoid*) 0));
                    glCheck(glVertexAttribPointer(1, 4,GL_UNSIGNED_BYTE,GL_TRUE,sizeof(Vertex),(GLvoid*) 12));
                    glCheck(glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*) 16));
                    glCheck(glEnableVertexAttribArray(3));
                    glCheck(glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.vboNormalBuffer));
                    glCheck(glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(sf::Vector3f), (GLvoid*) 0));
                    glCheck(glEnableVertexAttribArray(4));
                    /*glCheck(glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.vboTextureIndexesBuffer));

                    glCheck(glVertexAttribPointer(4, 1, GL_UNSIGNED_INT,GL_FALSE,sizeof(unsigned int),(GLvoid*) 0));
                    glCheck(glDisableVertexAttribArray(0));
                    glCheck(glDisableVertexAttribArray(1));
                    glCheck(glDisableVertexAttribArray(2));
                    glCheck(glDisableVertexAttribArray(3));
                    glCheck(glDisableVertexAttribArray(4));*/

                    glCheck(glBindBuffer(GL_ARRAY_BUFFER, 0));
                } else {
                    glCheck(glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.vboVertexBuffer));
                    glCheck(glEnableClientState(GL_COLOR_ARRAY));
                    glCheck(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
                    glCheck(glEnableClientState(GL_VERTEX_ARRAY));
                    glCheck(glVertexPointer(3, GL_FLOAT, sizeof(Vertex), (GLvoid*) 0 ));
                    glCheck(glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (GLvoid*) 12));
                    glCheck(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex),(GLvoid*) 16));
                    glCheck(glEnableClientState(GL_NORMAL_ARRAY));
                    glCheck(glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.vboNormalBuffer));
                    glCheck(glNormalPointer(GL_FLOAT, sizeof(sf::Vector3f), (GLvoid*) 0));
                    glCheck(glDisableClientState(GL_COLOR_ARRAY));
                    glCheck(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
                    glCheck(glDisableClientState(GL_VERTEX_ARRAY));
                    glCheck(glDisableClientState(GL_NORMAL_ARRAY));
                    glCheck(glBindBuffer(GL_ARRAY_BUFFER, 0));
                }
                m_cache.lastVboBuffer = &vertexBuffer;
            }
            if (m_versionMajor > 3 || m_versionMajor == 3 && m_versionMinor >= 3) {
                glCheck(glEnableVertexAttribArray(0));
                glCheck(glEnableVertexAttribArray(1));
                glCheck(glEnableVertexAttribArray(2));
                glCheck(glEnableVertexAttribArray(3));
                //glCheck(glEnableVertexAttribArray(4));
            } else {
                glCheck(glEnableClientState(GL_COLOR_ARRAY));
                glCheck(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
                glCheck(glEnableClientState(GL_VERTEX_ARRAY));
                glCheck(glEnableClientState(GL_NORMAL_ARRAY));
            }

            // Find the OpenGL primitive type
            static const GLenum modes[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES,
                                               GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS};
            GLenum mode = modes[vertexBuffer.getPrimitiveType()];
            if (vertexBuffer.m_indexes.size() > 0) {
                glCheck(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vertexBuffer.vboIndexBuffer));
                glCheck(glDrawElements(mode, vertexBuffer.m_indexes.size(), GL_UNSIGNED_INT, (GLvoid*) 0));
                glCheck(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
            } else {
                //std::cout<<"draw arrays"<<std::endl;
                glCheck(glBindFramebuffer(GL_FRAMEBUFFER, m_framebufferId));
                glCheck(glDrawArrays(mode, 0, vertexBuffer.getVertexCount()));
            }
            if (m_versionMajor > 3 || m_versionMajor == 3 && m_versionMinor >= 3) {
                glCheck(glDisableVertexAttribArray(0));
                glCheck(glDisableVertexAttribArray(1));
                glCheck(glDisableVertexAttribArray(2));
                glCheck(glDisableVertexAttribArray(3));
                //glCheck(glDisableVertexAttribArray(4));
                glCheck(glBindVertexArray(0));
            } else {
                glCheck(glDisableClientState(GL_COLOR_ARRAY));
                glCheck(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
                glCheck(glDisableClientState(GL_VERTEX_ARRAY));
                glCheck(glDisableClientState(GL_NORMAL_ARRAY));
            }
        }

    }

When I comment this line : glEnableVertexAttribArray(4) it works.

Ok now it doesn’t crash anymore but the values in my vertex shader are incorrect it should be one or it’s a very big value when I pass the texture index as an unsigned int.

Ok I used glVertexAttribIPointer and now it works.