Bug 31934

Summary: [gallium] Mapping empty buffer object causes SIGSEGV
Product: Mesa Reporter: Wiktor Janas <wixorpeek>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Wiktor Janas 2010-11-26 04:54:24 UTC
The following code triggers SIGSEGV at mesa/state_tracker/st_cb_bufferobjects.c:236, because st_obj->buffer is NULL.

#include <stdlib.h>

#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glut.h>

int main (int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA);
    glutInitWindowSize(512,512);
    glutCreateWindow("");

    GLuint id;
    glGenBuffersARB(1, &id);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, id);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, 0, NULL, GL_STATIC_DRAW);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);

    glBindBufferARB(GL_ARRAY_BUFFER_ARB, id);
    glMapBuffer(GL_ARRAY_BUFFER_ARB, GL_READ_WRITE_ARB); /* CRASH! */
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);

    return 0;
}
Comment 1 Brian Paul 2010-11-26 12:50:36 UTC
Fixed with commit 97ae4dad1cc24c5e969e6b99f07ece68e239964b.
Committed to the 7.9 branch too.  Thanks for the test program!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.