<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 in glLinkProgram with shaders with multiple constant arrays"
href="https://bugs.freedesktop.org/show_bug.cgi?id=89590">89590</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Crash in glLinkProgram with shaders with multiple constant arrays
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr>
<tr>
<th>Version</th>
<td>10.5
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>jlegg@feralinteractive.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=114347" name="attach_114347" title="Reproducer">attachment 114347</a> <a href="attachment.cgi?id=114347&action=edit" title="Reproducer">[details]</a></span>
Reproducer
glLinkProgram crashes if there are multiple shaders with used arrays of
constants attached to the program, and the arrays have different numbers of
elements. For example:
Vertex shader:
#version 330
in vec2 in_position;
void main()
{
const float zs[4] = float[4](0, 0, 0, 0);
gl_Position = vec4(in_position, zs[int(in_position.x) % 4], 1.0);
}
Fragment shader:
#version 330
void main()
{
const vec4 colours[2] = vec4[2](vec4(1, 0, 0, 0), vec4(0, 1, 0, 0));
gl_FragColor = colours[int(gl_FragCoord.x) % 2];
}
The attached program uses these shaders and reproduces the bug.
Backtrace from Mesa 10.5.1:
<span class="quote">> #0 linker::copy_constant_to_storage(gl_constant_value*, ir_constant const*, glsl_base_type, unsigned int, unsigned int) glsl/link_uniform_initializers.cpp:66
> #1 linker::set_uniform_initializer(void*, gl_shader_program*, char const*, glsl_type const*, ir_constant*, unsigned int) glsl/link_uniform_initializers.cpp:210
> #2 link_set_uniform_initializers(gl_shader_program*, unsigned int) glsl/link_uniform_initializers.cpp:309
> #3 link_assign_uniform_locations(gl_shader_program*, unsigned int) glsl/link_uniforms.cpp:1034
> #4 link_shaders(gl_context*, gl_shader_program*) glsl/linker.cpp:2869
> #5 _mesa_glsl_link_shader mesa/program/ir_to_mesa.cpp:3031
> #6 link_program mesa/main/shaderapi.c:932</span >
The second argument to linker::copy_constant_to_storage, val, appears bogus, as
it points to something near 0x0.
The arrays of constants do not have to be declared const in the shader, as long
as all the element's values are known at compile time.
I found this using an AMD PITCAIRN gpu on Fedora 21, x86_64 architecture.</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>