Bug 29946

Summary: [swrast] piglit valgrind glsl-array-bounds-04 fails
Product: Mesa Reporter: Vinson Lee <vlee>
Component: OtherAssignee: Brian Paul <brianp>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: All   
OS: Linux (All)   
i915 platform: i915 features:

Description Vinson Lee 2010-09-01 13:29:04 UTC
mesa: 4ff3467daf0ac07e4295c7d2e2ad3c3c8c89dff6 (master)

piglit valgrind glsl-array-bounds-04 fails with swrast.

$ valgrind --track-origins=yes shader_runner glsl-array-bounds-04.shader_test -auto

==19245== Conditional jump or move depends on uninitialised value(s)
==19245==    at 0x41C3286: _mesa_execute_program (prog_execute.c:1469)
==19245==    by 0x418EC65: run_vp (t_vb_program.c:380)
==19245==    by 0x418CF9C: _tnl_run_pipeline (t_pipeline.c:153)
==19245==    by 0x418E267: _tnl_draw_prims (t_draw.c:478)
==19245==    by 0x418DFD4: _tnl_vbo_draw_prims (t_draw.c:384)
==19245==    by 0x4180255: vbo_exec_DrawArrays (vbo_exec_array.c:526)
==19245==    by 0x4171630: neutral_DrawArrays (vtxfmt_tmp.h:327)
==19245==    by 0x804DE79: piglit_draw_rect (piglit-util.c:627)
==19245==    by 0x804C599: piglit_display (shader_runner.c:673)
==19245==    by 0x804E722: display (piglit-framework.c:52)
==19245==    by 0x44B981F: ??? (in /usr/lib/libglut.so.3.9.0)
==19245==    by 0x44BD65F: fgEnumWindows (in /usr/lib/libglut.so.3.9.0)
==19245==  Uninitialised value was created by a stack allocation
==19245==    at 0x418E9DC: run_vp (t_vb_program.c:309)
Comment 1 Ian Romanick 2010-09-09 18:35:08 UTC
Closing as not-a-bug.  The shader is intentionally reading outside the bounds of an array to verify that such a read does not result in program termination.  After performing the read, the shader tests the value read to ensure that the read is not optimized away.  The only way to eliminate this valgrind error would be to initialize all temps, uniforms, and varyings before executing a shader.  I don't think it's worth the effort or the potential performance hit.
Comment 2 Vinson Lee 2010-12-10 14:29:30 UTC
ommit ef3f7e61b314236cbb7ed2cf24d34c6f90d9cfca
Author: Vinson Lee <vlee@vmware.com>
Date:   Fri Dec 10 14:24:05 2010 -0800

    tnl: Initialize gl_program_machine memory in run_vp.
    Fixes piglit valgrind glsl-array-bounds-04 failure (FDO bug 29946).
    This is a candidate for the 7.10 branch.
    This is a candidate for the 7.9 branch.

diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 76f8fde..7e7c59a 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -311,7 +311,7 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage )
    struct vp_stage_data *store = VP_STAGE_DATA(stage);
    struct vertex_buffer *VB = &tnl->vb;
    struct gl_vertex_program *program = ctx->VertexProgram._Current;
-   struct gl_program_machine machine;
+   struct gl_program_machine machine = { 0 };
    GLuint outputs[VERT_RESULT_MAX], numOutputs;
    GLuint i, j;
Comment 3 Vinson Lee 2011-01-09 00:41:12 UTC
mesa: 3f94d96fce244bbe8a9edc15758729ce0e604ae2 (master)

Verified fixed.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.