Bug 73392 - GLX context memory leak if context was bound to drawable on thread exit
Summary: GLX context memory leak if context was bound to drawable on thread exit
Status: RESOLVED MOVED
Alias: None
Product: Mesa
Classification: Unclassified
Component: GLX (show other bugs)
Version: 9.2
Hardware: All Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-08 11:12 UTC by Rinat
Modified: 2019-09-18 17:44 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Rinat 2014-01-08 11:12:56 UTC
glXDestroyContext leaks memory if context was bound and there was no
glXMakeCurrent call before thread termination.

Here is sample code for reproduction.


// gcc glXDestroyContext-memleak.c -std=gnu99 -lpthread -lGL -lX11
#include <pthread.h>
#include <GL/glx.h>
#include <unistd.h>

GLXContext glc;
GLXContext root_glc;
Display *dpy;
XVisualInfo *xvi;

void *thread_func1(void *p)
{
    Window root_wnd = XDefaultRootWindow(dpy);
    glc = glXCreateContext(dpy, xvi, NULL, GL_TRUE);
    glXMakeCurrent(dpy, root_wnd, glc);
    glXDestroyContext(dpy, glc);
    return NULL;
}

int main(void) {
    GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
    dpy = XOpenDisplay(NULL);
    xvi = glXChooseVisual(dpy, 0, att);

    for (int k = 0; k < 30000; k ++) {
        pthread_t t;
        pthread_create(&t, NULL, thread_func1, NULL);
        pthread_join(t, NULL);
        sleep(1);
    }

    return 0;
}
Comment 1 GitLab Migration User 2019-09-18 17:44:38 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/92.


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.