Bug 107550 - "0[2]" as function parameter hits assert
Summary: "0[2]" as function parameter hits assert
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-12 17:40 UTC by Karol Herbst
Modified: 2018-08-15 07:11 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
shader.frag (53 bytes, text/plain)
2018-08-12 17:40 UTC, Karol Herbst
Details

Description Karol Herbst 2018-08-12 17:40:55 UTC
Created attachment 141050 [details]
shader.frag

gdb output:

glsl_compiler: ../src/compiler/glsl/ir.cpp:1094: ir_constant* ir_constant::get_array_element(unsigned int) const: Assertion `this->type->is_array()' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50        return ret;
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff6cc45c1 in __GI_abort () at abort.c:79
#2  0x00007ffff6cc4491 in __assert_fail_base (fmt=0x7ffff6e27248 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x545a54 "this->type->is_array()", file=0x544b92 "../src/compiler/glsl/ir.cpp", 
    line=1094, function=0x546a20 <ir_constant::get_array_element(unsigned int) const::__PRETTY_FUNCTION__> "ir_constant* ir_constant::get_array_element(unsigned int) const") at assert.c:92
#3  0x00007ffff6cd2752 in __GI___assert_fail (assertion=0x545a54 "this->type->is_array()", file=0x544b92 "../src/compiler/glsl/ir.cpp", line=1094, 
    function=0x546a20 <ir_constant::get_array_element(unsigned int) const::__PRETTY_FUNCTION__> "ir_constant* ir_constant::get_array_element(unsigned int) const") at assert.c:101
#4  0x0000000000464d60 in ir_constant::get_array_element (this=0xc24390, i=2) at ../src/compiler/glsl/ir.cpp:1094
#5  0x00000000004610ad in ir_dereference_array::constant_expression_value (this=0xc245f0, mem_ctx=0x7de6e0, variable_context=0x0) at ../src/compiler/glsl/ir_constant_expression.cpp:831
#6  0x00000000004ec22a in process_parameters (instructions=0xc24300, actual_parameters=0x7fffffffd5f0, parameters=0x7df9c8, state=0x7de6e0) at ../src/compiler/glsl/ast_function.cpp:53
#7  0x00000000004f2bc7 in ast_function_expression::hir (this=0x7df970, instructions=0xc24300, state=0x7de6e0) at ../src/compiler/glsl/ast_function.cpp:2339
#8  0x00000000004f541d in ast_function_expression::hir_no_rvalue (this=0x7df970, instructions=0xc24300, state=0x7de6e0) at ../src/compiler/glsl/ast_to_hir.cpp:1089
#9  0x00000000004f9102 in ast_expression_statement::hir (this=0x7dfbb0, instructions=0xc24300, state=0x7de6e0) at ../src/compiler/glsl/ast_to_hir.cpp:2227
#10 0x00000000004f9175 in ast_compound_statement::hir (this=0x7dfbf0, instructions=0xc24300, state=0x7de6e0) at ../src/compiler/glsl/ast_to_hir.cpp:2243
#11 0x0000000000501631 in ast_function_definition::hir (this=0x7dfc50, instructions=0x7e2ee0, state=0x7de6e0) at ../src/compiler/glsl/ast_to_hir.cpp:6191
#12 0x00000000004f3628 in _mesa_ast_to_hir (instructions=0x7e2ee0, state=0x7de6e0) at ../src/compiler/glsl/ast_to_hir.cpp:156
#13 0x0000000000452ea8 in _mesa_glsl_compile_shader (ctx=0x7ab1c0 <standalone_compile_shader::local_ctx>, shader=0x7dc5b0, dump_ast=false, dump_hir=false, force_recompile=true)
    at ../src/compiler/glsl/glsl_parser_extras.cpp:2119
#14 0x00000000004053c6 in compile_shader (ctx=0x7ab1c0 <standalone_compile_shader::local_ctx>, shader=0x7dc5b0) at ../src/compiler/glsl/standalone.cpp:394
#15 0x0000000000405915 in standalone_compile_shader (_options=0x7ab170 <options>, num_files=1, files=0x7fffffffdc70) at ../src/compiler/glsl/standalone.cpp:504
#16 0x0000000000404738 in main (argc=4, argv=0x7fffffffdc58) at ../src/compiler/glsl/main.cpp:95
Comment 1 Tapani Pälli 2018-08-15 07:11:28 UTC
commit 479a849ad606482c3cf67157b77af94ecd450ace
Author: Danylo Piliaiev <danylo.piliaiev@gmail.com>
Date:   Mon Aug 13 18:57:38 2018 +0300

    glsl: Avoid calling get_array_element for scalar constants
    
    Accessing scalar constant as an array in function call or
    initializer list triggered assert in get_array_element.
    Examples:
       func(0[0]);
       vec2 t = { 0[0], 0 };
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107550
    
    Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
    Reviewed-by: Tapani Pälli <tapani.palli@intel.com>


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.