<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 --- - r600g: 'invalid read' linking geometry shader"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=74717">74717</a>
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>airlied@freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dri-devel@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>r600g: 'invalid read' linking geometry shader
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>edwin+mesa@etorok.net
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/Gallium/r600
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=93669" name="attach_93669" title="gl-320-primitive-shading.trace">attachment 93669</a> <a href="attachment.cgi?id=93669&action=edit" title="gl-320-primitive-shading.trace">[details]</a></span>
gl-320-primitive-shading.trace

I am happy that r600g gained OpenGL 3.3 support in Mesa, so I tested a few
geometry shader samples.

gl-320-primitive-shading either segfaults or prints error messages when run.
According to valgrind there is an invalid read when linking the shader. I have
reproduced the invalid read with glretrace too (see attachment).

Kernel is 3.14.0-rc1 + merge of 7c4c62a04a2a80e3feb5d6c97aca1e413b11c790 from
drm-fixes:
$ uname -a
Linux debian 3.14.0-rc1-00015-g7c4c62a #48 SMP PREEMPT Sat Feb 8 17:33:48 EET
2014 x86_64 GNU/Linux

Mesa is from the 10.1 branch:
$ glxinfo |grep OpenGL
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD RV730
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.1.0-rc1
(git-1e6bba5)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.1.0-rc1 (git-1e6bba5)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:

Hardware is a Radeon HD 4650:
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] RV730
PRO [Radeon HD 4650] (prog-if 00 [VGA controller])

To reproduce using the source code:
$ git clone <a href="https://github.com/g-truc/ogl-samples">https://github.com/g-truc/ogl-samples</a>
$ cmake .
$ make 
$ build/build/release/gl-320-primitive-shading

The relevant source files:
<a href="https://github.com/g-truc/ogl-samples/blob/master/samples/gl-320-primitive-shading.cpp">https://github.com/g-truc/ogl-samples/blob/master/samples/gl-320-primitive-shading.cpp</a>
<a href="https://github.com/g-truc/ogl-samples/blob/master/data/gl-320/primitive-shading.frag">https://github.com/g-truc/ogl-samples/blob/master/data/gl-320/primitive-shading.frag</a>
<a href="https://github.com/g-truc/ogl-samples/blob/master/data/gl-320/primitive-shading.geom">https://github.com/g-truc/ogl-samples/blob/master/data/gl-320/primitive-shading.geom</a>
<a href="https://github.com/g-truc/ogl-samples/blob/master/data/gl-320/primitive-shading.vert">https://github.com/g-truc/ogl-samples/blob/master/data/gl-320/primitive-shading.vert</a>

Running 'valgrind glretrace gl-320-primitive-shading.trace' shows:
==10728== Memcheck, a memory error detector
==10728== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==10728== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==10728== Command: glretrace gl-320-primitive-shading.trace
==10728== 
==10728== Invalid read of size 8
==10728==    at 0x58131A0: glsl_to_tgsi_visitor::copy_propagate()
(st_glsl_to_tgsi.cpp:3447)
==10728==    by 0x581AE1F: st_link_shader (st_glsl_to_tgsi.cpp:5126)
==10728==    by 0x582EDD9: _mesa_glsl_link_shader (ir_to_mesa.cpp:3091)
==10728==    by 0x577E729: link_program (shaderapi.c:872)
==10728==    by 0x47D8B3: _glLinkProgram(unsigned int) (in
/usr/local/bin/glretrace)
==10728==    by 0x4E7411: retrace_glLinkProgram(trace::Call&) (in
/usr/local/bin/glretrace)
==10728==    by 0x429EDC: retrace::Retracer::retrace(trace::Call&) (in
/usr/local/bin/glretrace)
==10728==    by 0x41F7F8: retrace::retraceCall(trace::Call*) (in
/usr/local/bin/glretrace)
==10728==    by 0x421681: retrace::RelayRunner::runLeg(trace::Call*) (in
/usr/local/bin/glretrace)
==10728==    by 0x421573: retrace::RelayRunner::runRace() (in
/usr/local/bin/glretrace)
==10728==    by 0x41FB49: retrace::RelayRace::run() (in
/usr/local/bin/glretrace)
==10728==    by 0x41FD18: retrace::mainLoop() (in /usr/local/bin/glretrace)
==10728==  Address 0x8517a88 is not stack'd, malloc'd or (recently) free'd
==10728== 
==10728== Invalid read of size 8
==10728==    at 0x58131B6: glsl_to_tgsi_visitor::copy_propagate()
(st_glsl_to_tgsi.cpp:3459)
==10728==    by 0x581AE1F: st_link_shader (st_glsl_to_tgsi.cpp:5126)
==10728==    by 0x582EDD9: _mesa_glsl_link_shader (ir_to_mesa.cpp:3091)
==10728==    by 0x577E729: link_program (shaderapi.c:872)
==10728==    by 0x47D8B3: _glLinkProgram(unsigned int) (in
/usr/local/bin/glretrace)
==10728==    by 0x4E7411: retrace_glLinkProgram(trace::Call&) (in
/usr/local/bin/glretrace)
==10728==    by 0x429EDC: retrace::Retracer::retrace(trace::Call&) (in
/usr/local/bin/glretrace)
==10728==    by 0x41F7F8: retrace::retraceCall(trace::Call*) (in
/usr/local/bin/glretrace)
==10728==    by 0x421681: retrace::RelayRunner::runLeg(trace::Call*) (in
/usr/local/bin/glretrace)
==10728==    by 0x421573: retrace::RelayRunner::runRace() (in
/usr/local/bin/glretrace)
==10728==    by 0x41FB49: retrace::RelayRace::run() (in
/usr/local/bin/glretrace)
==10728==    by 0x41FD18: retrace::mainLoop() (in /usr/local/bin/glretrace)
==10728==  Address 0x188 is not stack'd, malloc'd or (recently) free'd
==10728== 
apitrace: warning: caught signal 11
5394: error: caught an unhandled exception

Running it without valgrind shows this:
$ glretrace gl-320-primitive-shading.trace
EE r600_shader.c:345 tgsi_is_supported - unsupported src 0 (dimension 1)
EE r600_shader.c:157 r600_pipe_shader_create - translation from TGSI failed !
EE r600_state_common.c:745 r600_shader_select - Failed to build shader variant
(type=2) -22
EE r600_shader.c:345 tgsi_is_supported - unsupported src 0 (dimension 1)
EE r600_shader.c:157 r600_pipe_shader_create - translation from TGSI failed !
EE r600_state_common.c:745 r600_shader_select - Failed to build shader variant
(type=2) -22</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>