Bug 38625 - ast_to_hir.cpp:1761: const glsl_type* process_array_type(YYLTYPE*, const glsl_type*, ast_node*, _mesa_glsl_parse_state*): Assertion `dummy_instructions.is_empty()' failed.
ast_to_hir.cpp:1761: const glsl_type* process_array_type(YYLTYPE*, const glsl...
Status: CLOSED FIXED
Product: Mesa
Classification: Unclassified
Component: glsl-compiler
git
x86 (IA32) Linux (All)
: medium critical
Assigned To: Paul Berry
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-23 16:55 UTC by Vinson Lee
Modified: 2011-08-18 19:30 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vinson Lee 2011-06-23 16:55:32 UTC
mesa: 9c5d15e929f47f517f90977f5420e11dfbd3db67 (master)

Run piglt "glsl-1.20 compiler structure-and-array-operations array-size-constant-relational" test on swrast or softpipe.

$ ./bin/glslparsertest tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-constant-relational.vert pass 1.20
glslparsertest: ast_to_hir.cpp:1761: const glsl_type* process_array_type(YYLTYPE*, const glsl_type*, ast_node*, _mesa_glsl_parse_state*): Assertion `dummy_instructions.is_empty()' failed.


(gdb) bt
#0  0x00815416 in __kernel_vsyscall ()
#1  0x00b2f941 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0x00b32e42 in abort () at abort.c:92
#3  0x00b288e8 in __assert_fail (assertion=0x6423e8 "dummy_instructions.is_empty()", file=0x641956 "ast_to_hir.cpp", line=1761, 
    function=0x643840 "const glsl_type* process_array_type(YYLTYPE*, const glsl_type*, ast_node*, _mesa_glsl_parse_state*)") at assert.c:81
#4  0x004f3829 in process_array_type (loc=0xbfc8b2b8, base=0x714ac0, array_size=0x91c6998, state=0x91c1f68) at ast_to_hir.cpp:1761
#5  0x004f3a00 in ast_type_specifier::glsl_type (this=0x91c6610, name=0xbfc8b370, state=0x91c1f68) at ast_to_hir.cpp:1805
#6  0x004f4d53 in ast_declarator_list::hir (this=0x91c6a78, instructions=0x8eb3230, state=0x91c1f68) at ast_to_hir.cpp:2390
#7  0x004eeed7 in _mesa_ast_to_hir (instructions=0x8eb3230, state=0x91c1f68) at ast_to_hir.cpp:85
#8  0x004ecd3f in _mesa_glsl_compile_shader (ctx=0x8e7fbf0, shader=0x91c0750) at program/ir_to_mesa.cpp:3189
#9  0x0040af91 in compile_shader (ctx=0x8e7fbf0, shaderObj=1) at main/shaderapi.c:848
#10 0x0040b955 in _mesa_CompileShaderARB (shaderObj=1) at main/shaderapi.c:1188
#11 0x08069457 in test ()
#12 0x0806988e in main ()
(gdb) frame 4
#4  0x004f3829 in process_array_type (loc=0xbfc8b2b8, base=0x714ac0, array_size=0x91c6998, state=0x91c1f68) at ast_to_hir.cpp:1761
1761	      assert(dummy_instructions.is_empty());
Comment 1 Paul Berry 2011-08-01 16:17:43 UTC
I tracked this down to a flaw in Mesa's ast-to-hir conversion.  When a built-in function was used in computing an array size, Mesa correctly computed the constant array size, but it emitted some unnecessary IR in the process.  That IR had no place to go (since no IR is expected for constant values) so an assertion fired.

I've submitted a patch series for review that:
- ensures that no IR is generated when a built-in function is used in computing a constant value, and
- delays the assertion so that if the user attempts to declare an array with a non-constant size, they will get an error message rather than a crash.

If all goes well, the patch should land in master in a few days.
Comment 2 Paul Berry 2011-08-10 14:43:09 UTC
Fixed in commit 789ee6516bfca289e1948ff8f2c147b94286a0e0.
Comment 3 Vinson Lee 2011-08-18 19:30:12 UTC
mesa: ccecc08f79afc020c8c0acface04a8e53e3a7c32 (master)

Verified fixed.