<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 happens when running compute pipeline after calling glxMakeCurrent two times"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=104546">104546</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash happens when running compute pipeline after calling glxMakeCurrent two times
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>git
          </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>major
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Drivers/DRI/i965
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>xinghua.cao@intel.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Reproduce steps:
1. Attached file is the C source code;
2. Build the source file, "gcc -o test test.c -lX11 -lepoxy";
3. run "./test", crash happens.

Actually, I summerized above case from ANGLE project, the crash issue was found
on ANGLE project initially. If you want to produce this issue on ANGLE, follow
below steps:
1. Download ANGLE source code, <a href="https://github.com/google/angle">https://github.com/google/angle</a>
2. Build it follow ./doc/DevSetup.md document
3. run "./angle_deqp_gles31_tests
--gtest_filter=dEQP_GLES31.Default/functional_synchronization_in_invocation_image_write_read
"

I had also debugged this issue in mesa, crash for attempting to access a null
pointer, the call stack is as below,
#0  0x00007ffff356d818 in intel_disable_rb_aux_buffer (brw=0x7ffff7fc9040,
tex_mt=0x5555558eb910, min_level=0, num_levels=4294967295, usage=0x7ffff3b8c0ad
"as a shader image") at brw_draw.c:359
#1  0x00007ffff356dc8e in brw_predraw_resolve_inputs (brw=0x7ffff7fc9040,
rendering=false) at brw_draw.c:444
#2  0x00007ffff35644b1 in brw_dispatch_compute_common (ctx=0x7ffff7fc9040) at
brw_compute.c:180
#3  0x00007ffff35646f0 in brw_dispatch_compute (ctx=0x7ffff7fc9040,
num_groups=0x7fffffffdd9c) at brw_compute.c:234
#4  0x00007ffff30786cd in dispatch_compute (no_error=false, num_groups_z=1,
num_groups_y=2, num_groups_x=1) at main/compute.c:265
#5  _mesa_DispatchCompute (num_groups_x=1, num_groups_y=2, num_groups_z=1) at
main/compute.c:280

In intel_disable_rb_aux_buffer function, the mip tree of renderbuffer is not
created, irb->mt is null pointer,
   if (irb && irb->mt->bo == tex_mt->bo &&       // crash here
          irb->mt_level >= min_level &&
          irb->mt_level < min_level + num_levels)

The second drawable overrides the first one when call glXMakeCurrent the second
time. In ./i965/brw_context.c::intelMakeCurrent function,
brw->ctx.ViewportInitialized is setted to true when call glXMakeCurrent the
first time, it does not call intel_prepare_render to update the render buffer
when call glXMakeCurrent the second time, the mip tree is not created.
Because currently use computation pipeline, so it seems that render buffer does
need to real memory buffer and mip tree, is it right? Is it a mesa bug? Or Do
we use the apis incorrectly?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>