[10/11] st/glsl_to_nir: Fix uninitialized access

Submitted by Tomeu Vizoso on May 9, 2019, 6:35 a.m.

Details

Message ID 20190509063511.62982-11-tomeu.vizoso@collabora.com
State New
Headers show
Series "panfrost: ci: RK3288 support and misc robustness" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Tomeu Vizoso May 9, 2019, 6:35 a.m.
NIR_PASS will only set lower_flrp_progress if there's progress, and if
there isn't its value will be undefined.

Fixes this Valgrind error:

==6589== Conditional jump or move depends on uninitialised value(s)
==6589==    at 0x55CA7E6: st_nir_opts (st_glsl_to_nir.cpp:347)
==6589==    by 0x55CC1DD: st_nir_link_shaders(nir_shader**, nir_shader**, bool) (st_glsl_to_nir.cpp:667)
==6589==    by 0x55CCDAB: st_link_nir (st_glsl_to_nir.cpp:803)
==6589==    by 0x55C8C5F: st_link_shader (st_glsl_to_ir.cpp:167)
==6589==    by 0x5438B11: _mesa_glsl_link_shader (ir_to_mesa.cpp:3170)
==6589==    by 0x5371701: link_program (shaderapi.c:1216)
==6589==    by 0x5371701: link_program_error (shaderapi.c:1310)
==6589==    by 0x5372901: _mesa_LinkProgram (shaderapi.c:1802)
==6589==    by 0x509B459: shared_dispatch_stub_509 (glapi_mapi_tmp.h:21115)
==6589==    by 0x4799BF: glu::Program::link() (in /home/tomeu/deqp-build/modules/gles2/deqp-gles2)
==6589==    by 0x47A253: glu::ShaderProgram::init(glw::Functions const&, glu::ProgramSources const&) (in /home/tomeu/deqp-build/modules/gles2/deqp-gles2)

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Fixes: d41cdef2a591 ("nir: Use the flrp lowering pass instead of nir_opt_algebraic")
Cc: Ian Romanick <ian.d.romanick@intel.com>
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 0a67d4532eba..57064251313c 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -338,7 +338,7 @@  st_nir_opts(nir_shader *nir, bool scalar)
       NIR_PASS(progress, nir, nir_opt_constant_folding);
 
       if (lower_flrp != 0) {
-         bool lower_flrp_progress;
+         bool lower_flrp_progress = false;
 
          NIR_PASS(lower_flrp_progress, nir, nir_lower_flrp,
                   lower_flrp,

Comments

On Thu, 9 May 2019 at 07:35, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
>
> NIR_PASS will only set lower_flrp_progress if there's progress, and if
> there isn't its value will be undefined.
>
> Fixes this Valgrind error:
>
> ==6589== Conditional jump or move depends on uninitialised value(s)
> ==6589==    at 0x55CA7E6: st_nir_opts (st_glsl_to_nir.cpp:347)
> ==6589==    by 0x55CC1DD: st_nir_link_shaders(nir_shader**, nir_shader**, bool) (st_glsl_to_nir.cpp:667)
> ==6589==    by 0x55CCDAB: st_link_nir (st_glsl_to_nir.cpp:803)
> ==6589==    by 0x55C8C5F: st_link_shader (st_glsl_to_ir.cpp:167)
> ==6589==    by 0x5438B11: _mesa_glsl_link_shader (ir_to_mesa.cpp:3170)
> ==6589==    by 0x5371701: link_program (shaderapi.c:1216)
> ==6589==    by 0x5371701: link_program_error (shaderapi.c:1310)
> ==6589==    by 0x5372901: _mesa_LinkProgram (shaderapi.c:1802)
> ==6589==    by 0x509B459: shared_dispatch_stub_509 (glapi_mapi_tmp.h:21115)
> ==6589==    by 0x4799BF: glu::Program::link() (in /home/tomeu/deqp-build/modules/gles2/deqp-gles2)
> ==6589==    by 0x47A253: glu::ShaderProgram::init(glw::Functions const&, glu::ProgramSources const&) (in /home/tomeu/deqp-build/modules/gles2/deqp-gles2)
>
> Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> Fixes: d41cdef2a591 ("nir: Use the flrp lowering pass instead of nir_opt_algebraic")
> Cc: Ian Romanick <ian.d.romanick@intel.com>

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

Thanks
Emil
On Thu, 9 May 2019 at 15:49, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>
> On Thu, 9 May 2019 at 07:35, Tomeu Vizoso <tomeu.vizoso@collabora.com> wrote:
> >
> > NIR_PASS will only set lower_flrp_progress if there's progress, and if
> > there isn't its value will be undefined.
> >
> > Fixes this Valgrind error:
> >
> > ==6589== Conditional jump or move depends on uninitialised value(s)
> > ==6589==    at 0x55CA7E6: st_nir_opts (st_glsl_to_nir.cpp:347)
> > ==6589==    by 0x55CC1DD: st_nir_link_shaders(nir_shader**, nir_shader**, bool) (st_glsl_to_nir.cpp:667)
> > ==6589==    by 0x55CCDAB: st_link_nir (st_glsl_to_nir.cpp:803)
> > ==6589==    by 0x55C8C5F: st_link_shader (st_glsl_to_ir.cpp:167)
> > ==6589==    by 0x5438B11: _mesa_glsl_link_shader (ir_to_mesa.cpp:3170)
> > ==6589==    by 0x5371701: link_program (shaderapi.c:1216)
> > ==6589==    by 0x5371701: link_program_error (shaderapi.c:1310)
> > ==6589==    by 0x5372901: _mesa_LinkProgram (shaderapi.c:1802)
> > ==6589==    by 0x509B459: shared_dispatch_stub_509 (glapi_mapi_tmp.h:21115)
> > ==6589==    by 0x4799BF: glu::Program::link() (in /home/tomeu/deqp-build/modules/gles2/deqp-gles2)
> > ==6589==    by 0x47A253: glu::ShaderProgram::init(glw::Functions const&, glu::ProgramSources const&) (in /home/tomeu/deqp-build/modules/gles2/deqp-gles2)
> >
> > Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> > Fixes: d41cdef2a591 ("nir: Use the flrp lowering pass instead of nir_opt_algebraic")
> > Cc: Ian Romanick <ian.d.romanick@intel.com>
>
> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
>
Ian has a MR [1] which addresses all use-cases, so I guess you can
drop this in favour of this patch.

-Emil
[1] https://gitlab.freedesktop.org/mesa/mesa/merge_requests/839

> Thanks
> Emil