<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - GLX context memory leak if context was bound to drawable on thread exit"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=73392">73392</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>GLX context memory leak if context was bound to drawable on thread exit
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ibragimovrinat@mail.ru
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>GLX
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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;
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>