<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Crash when creating new context after destroying the old one using indirect rendering"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=91687">91687</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash when creating new context after destroying the old one using indirect rendering
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.5
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

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

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

        <tr>
          <th>Severity</th>
          <td>critical
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Mesa core
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>gqmelo@gmail.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=117783" name="attach_117783" title="VTK/Qt Python program that crashes">attachment 117783</a> <a href="attachment.cgi?id=117783&action=edit" title="VTK/Qt Python program that crashes">[details]</a></span>
VTK/Qt Python program that crashes

I tested that on mesa Ubuntu 14.04 (mesa 10.3.2) and 15.10 (mesa 10.5.2). I'm
not sure if it is reproducible. The attached traces were gotten on Ubuntu
14.04.

The crash happens when running the attached python program crash_mesa_vtk_qt.py
using indirect rendering (specifically I need to run it inside a chroot that
has a very old mesa version)

It uses vtk and Qt, I'm sorry I could not come up with a more isolated example,
but I'm not very familiar with opengl programming.


In summary, that is what is happening:

1 - A vtk render window is created and rendered the first time (that makes vtk
create a new glx context)

2 - The vtk render window is set to render offscreen (it is not using OSMesa).
That makes vtk destroy the current context and create a new one associated to a
new X offscreen window.

3 - The window is rendered and I could even generate a png file.

4 - The vtk render window is set to render on screen again. That makes vtk
destroy the current glx context and create a new one associated to the first X
window (the on screen window).

5 - When rendering the vtk window again, X server crashes (stack trace
attached).


Looking into vtk code it does not seem it is doing anything wrong. The
offscreen related code can be found on:

<a href="https://gitlab.kitware.com/vtk/vtk/blob/v6.2.0/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx#L800">https://gitlab.kitware.com/vtk/vtk/blob/v6.2.0/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx#L800</a>

<a href="https://gitlab.kitware.com/vtk/vtk/blob/v6.2.0/Rendering/OpenGL/vtkOpenGLRenderWindow.cxx#L1856">https://gitlab.kitware.com/vtk/vtk/blob/v6.2.0/Rendering/OpenGL/vtkOpenGLRenderWindow.cxx#L1856</a>

<a href="https://gitlab.kitware.com/vtk/vtk/blob/v6.2.0/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx#L943">https://gitlab.kitware.com/vtk/vtk/blob/v6.2.0/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx#L943</a>

<a href="https://gitlab.kitware.com/vtk/vtk/blob/v6.2.0/Rendering/OpenGL/vtkOpenGLRenderWindow.cxx#L1856">https://gitlab.kitware.com/vtk/vtk/blob/v6.2.0/Rendering/OpenGL/vtkOpenGLRenderWindow.cxx#L1856</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>