Bug 109488

Summary: Mesa 18.3.2 crash on a specific fragment shader (assert triggered) / already fixed on the master branch.
Product: Mesa Reporter: Patrick <patrick9876>
Component: glsl-compilerAssignee: Emil Velikov <emil.l.velikov>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: major    
Priority: medium    
Version: 18.3   
Hardware: x86-64 (AMD64)   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Patrick 2019-01-28 20:44:27 UTC
The following shader: https://www.shadertoy.com/view/ll3fz4 generates an assert. The issue is fixed after applying the following commit: 76c27e47b90647df047e785d6b3ab5d0d979a1ee available on the master branch.

This commit: 76c27e47b90647df047e785d6b3ab5d0d979a1ee   is likely required on the stable branch too.

With Mesa 18.3.2:
#3  0x00007ffff6ade5f2 in __assert_fail () from /lib64/libc.so.6
#4  0x00007ffff0693686 in (anonymous namespace)::ir_constant_variable_visitor::visit_enter (this=0x7fffffff8680, ir=0x147c470) at glsl/opt_constant_variable.cpp:161
#5  0x00007ffff058962e in ir_call::accept (this=0x147c470, v=0x7fffffff8680) at glsl/ir_hv_accept.cpp:326
#6  0x00007ffff0588968 in visit_list_elements (v=0x7fffffff8680, l=0x14736c0, statement_list=true) at glsl/ir_hv_accept.cpp:55
#7  0x00007ffff0588a96 in ir_loop::accept (this=0x14736a0, v=0x7fffffff8680) at glsl/ir_hv_accept.cpp:89
#8  0x00007ffff0588968 in visit_list_elements (v=0x7fffffff8680, l=0x1471e90, statement_list=true) at glsl/ir_hv_accept.cpp:55
#9  0x00007ffff058883c in ir_hierarchical_visitor::run (this=0x7fffffff8680, instructions=0x1471e90) at glsl/ir_hierarchical_visitor.cpp:364
#10 0x00007ffff06937f5 in do_constant_variable (instructions=0x1471e90) at glsl/opt_constant_variable.cpp:191
#11 0x00007ffff069397a in do_constant_variable_unlinked (instructions=0xc78570) at glsl/opt_constant_variable.cpp:217
#12 0x00007ffff0559c2d in do_common_optimization (ir=0xc78570, linked=false, uniform_locations_assigned=false, options=0xcb2120, native_integers=true) at glsl/glsl_parser_extras.cpp:2243
#13 0x00007ffff0559273 in opt_shader_and_create_symbol_table (ctx=0xcb1160, source_symbols=0x0, shader=0x11db210) at glsl/glsl_parser_extras.cpp:2010
#14 0x00007ffff05594eb in _mesa_glsl_compile_shader (ctx=0xcb1160, shader=0x11db210, dump_ast=false, dump_hir=false, force_recompile=true) at glsl/glsl_parser_extras.cpp:2093
#15 0x00007ffff06a5158 in compile_shaders (ctx=0xcb1160, prog=0x11e92b0) at glsl/shader_cache.cpp:73
#16 0x00007ffff06a585f in shader_cache_read_program_metadata (ctx=0xcb1160, prog=0x11e92b0) at glsl/shader_cache.cpp:232
#17 0x00007ffff05c3b4f in link_shaders (ctx=0xcb1160, prog=0x11e92b0) at glsl/linker.cpp:4879
#18 0x00007ffff0475a05 in _mesa_glsl_link_shader (ctx=0xcb1160, prog=0x11e92b0) at program/ir_to_mesa.cpp:3160
#19 0x00007ffff02fb9e6 in link_program (no_error=false, shProg=0x11e92b0, ctx=0xcb1160) at main/shaderapi.c:1206
#20 link_program_error (ctx=0xcb1160, shProg=0x11e92b0) at main/shaderapi.c:1286
#21 0x00007ffff02fd181 in _mesa_LinkProgram (programObj=16) at main/shaderapi.c:1778
#22 0x00007ffff55e5254 in compile_program (fslocalp=0x7ffff55f35a0 <fsprogram>) at shaderplayopengl.c:299
#23 0x00007ffff55e66bd in setup_createprogram (fslocalp=0x7ffff55f35a0 <fsprogram>, root=1) at shaderplayopengl.c:472
#24 0x00007ffff55e3e4e in context_reset () at libretro-shaderplay.c:1660
Comment 1 Mark Janes 2019-01-28 21:18:59 UTC
Matt, should Timothy's patch have been CC'd to stable when you pushed it?
Comment 2 Matt Turner 2019-01-28 22:33:20 UTC
It wasn't clear to me that it fixed any existing issue.

If we cherry-pick that commit, then we also need to cherry-pick

commit 0862929bf64222e85e8242824aecf05e494c157c
Author: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Date:   Thu Jan 10 18:16:59 2019 +0200

    glsl: Fix copying function's out to temp if dereferenced by array

as well.

Reassigning to the 18.3 branch maintainer, Emil.
Comment 3 Emil Velikov 2019-02-01 11:17:32 UTC
The patches have landed in 18.3.3 and should address the issue.
Huge thanks for tracking the fix and reporting it.

commit f2c1d7acd0ca56a020a982425523ec8f7fade966
Author: Timothy Arceri <tarceri@itsqueeze.com>
Date:   Mon Apr 9 14:40:40 2018 +1000

    glsl: Copy function out to temp if we don't directly ref a variable


commit 871aea89fd334203c331e7a086738ec59458e1d9
Author: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Date:   Thu Jan 10 18:16:59 2019 +0200

    glsl: Fix copying function's out to temp if dereferenced by array

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.