Bug 100438 - glsl/ir.cpp:1376: ir_dereference_variable::ir_dereference_variable(ir_variable*): Assertion `var != NULL' failed.
Summary: glsl/ir.cpp:1376: ir_dereference_variable::ir_dereference_variable(ir_variabl...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: 11.1
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords: bisected, regression
: 102265 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-03-28 23:06 UTC by Vinson Lee
Modified: 2017-11-20 00:07 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Vinson Lee 2017-03-28 23:06:36 UTC
mesa: 7ee91af30074a4381e4353122319e3b4b3fe7cbd (master 17.1.0-devel)

This GLSL shader triggers an assert.

void main()
{
  a[b](c);
}


$ ./src/compiler/glsl_compiler --version 110 test.frag 
glsl_compiler: glsl/ir.cpp:1376: ir_dereference_variable::ir_dereference_variable(ir_variable*): Assertion `var != NULL' failed.
Aborted (core dumped)

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
#1  0x00007f4f4e7363ea in __GI_abort () at abort.c:89
#2  0x00007f4f4e72cbb7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x56396212559c "var != NULL", file=file@entry=0x56396210d127 "glsl/ir.cpp", line=line@entry=1376, 
    function=function@entry=0x56396210dfa0 <ir_dereference_variable::ir_dereference_variable(ir_variable*)::__PRETTY_FUNCTION__> "ir_dereference_variable::ir_dereference_variable(ir_variable*)") at assert.c:92
#3  0x00007f4f4e72cc62 in __GI___assert_fail (assertion=assertion@entry=0x56396212559c "var != NULL", file=file@entry=0x56396210d127 "glsl/ir.cpp", line=line@entry=1376, 
    function=function@entry=0x56396210dfa0 <ir_dereference_variable::ir_dereference_variable(ir_variable*)::__PRETTY_FUNCTION__> "ir_dereference_variable::ir_dereference_variable(ir_variable*)") at assert.c:101
#4  0x0000563962038087 in ir_dereference_variable::ir_dereference_variable (var=0x0, this=<optimized out>) at glsl/ir.cpp:1376
#5  0x0000563962077f67 in ir_dereference_variable::ir_dereference_variable (var=0x0, this=<optimized out>) at ../../src/compiler/glsl/list.h:58
#6  ir_dereference_array::ir_dereference_array (this=0x56396387c710, var=0x0, array_index=0x56396387c530) at glsl/ir.cpp:1399
#7  0x0000563962101144 in generate_array_index (mem_ctx=mem_ctx@entry=0x56396386cc40, instructions=instructions@entry=0x56396387c4a0, state=state@entry=0x56396386cc40, loc=..., array=<optimized out>, idx=<optimized out>, function_name=function_name@entry=0x7ffdbdfbcf50, 
    actual_parameters=0x7ffdbdfbcfc0) at glsl/ast_function.cpp:668
#8  0x00005639621051eb in ast_function_expression::hir (this=0x56396386df68, instructions=0x56396387c4a0, state=0x56396386cc40) at glsl/ast_function.cpp:2191
#9  0x00005639620c2273 in ast_expression_statement::hir (this=<optimized out>, instructions=<optimized out>, state=<optimized out>) at glsl/ast_to_hir.cpp:2201
#10 0x00005639620c22cf in ast_compound_statement::hir (this=0x56396386e0d8, instructions=0x56396387c4a0, state=0x56396386cc40) at glsl/ast_to_hir.cpp:2217
#11 0x00005639620c8a6c in ast_function_definition::hir (this=0x56396386e138, instructions=<optimized out>, state=0x56396386cc40) at glsl/ast_to_hir.cpp:5845
#12 0x00005639620bee28 in _mesa_ast_to_hir (instructions=0x56396386e8b0, state=state@entry=0x56396386cc40) at glsl/ast_to_hir.cpp:155
#13 0x000056396206ff5f in _mesa_glsl_compile_shader (ctx=ctx@entry=0x5639623687a0 <standalone_compile_shader::local_ctx>, shader=shader@entry=0x56396386ad10, dump_ast=<optimized out>, dump_hir=<optimized out>, force_recompile=force_recompile@entry=true)
    at glsl/glsl_parser_extras.cpp:1984
#14 0x000056396203c2cc in compile_shader (ctx=ctx@entry=0x5639623687a0 <standalone_compile_shader::local_ctx>, shader=shader@entry=0x56396386ad10) at glsl/standalone.cpp:385
#15 0x000056396203c6fb in standalone_compile_shader (_options=<optimized out>, num_files=<optimized out>, files=<optimized out>) at glsl/standalone.cpp:488
#16 0x0000563962038cdb in main (argc=<optimized out>, argv=0x7ffdbdfbd498) at glsl/main.cpp:92
(gdb) frame 4
#4  0x0000563962038087 in ir_dereference_variable::ir_dereference_variable (var=0x0, this=<optimized out>) at glsl/ir.cpp:1376
1376	   assert(var != NULL);
(gdb) print var
$1 = (ir_variable *) 0x0


fd01840c0bd3b22d058a65a17ad30e3b45813b60 is the first bad commit
commit fd01840c0bd3b22d058a65a17ad30e3b45813b60
Author: Timothy Arceri <t_arceri@yahoo.com.au>
Date:   Wed Aug 5 15:49:22 2015 +1000

    glsl: add AoA support to subroutines
    
    process_parameters() will now be called earlier because we need
    actual_parameters processed earlier so we can use it with
    match_subroutine_by_name() to get the subroutine variable, we need
    to do this inside the recursive function generate_array_index() because
    we can't create the ir_dereference_array() until we have gotten to the
    outermost array.
    
    For the remainder of the array dimensions the type doesn't matter so we
    can just use the existing _mesa_ast_array_index_to_hir() function to
    process the ast.
    
    Reviewed-by: Dave Airlie <airlied@redhat.com>

:040000 040000 6fd2725cb11bcd8a8339a426017a93474d8fe261 dd66f0eaee3f686a47397a886d25917ed452397e M	src
bisect run success
Comment 1 Timothy Arceri 2017-03-29 00:16:21 UTC
(In reply to Vinson Lee from comment #0)
> mesa: 7ee91af30074a4381e4353122319e3b4b3fe7cbd (master 17.1.0-devel)
> 
> This GLSL shader triggers an assert.
> 
> void main()
> {
>   a[b](c);
> }
> 
> 

Can you send as a piglit test if this is not happening in piglit currently?
Comment 2 Vinson Lee 2017-04-08 04:08:40 UTC
(In reply to Timothy Arceri from comment #1)
> (In reply to Vinson Lee from comment #0)
> > mesa: 7ee91af30074a4381e4353122319e3b4b3fe7cbd (master 17.1.0-devel)
> > 
> > This GLSL shader triggers an assert.
> > 
> > void main()
> > {
> >   a[b](c);
> > }
> > 
> > 
> 
> Can you send as a piglit test if this is not happening in piglit currently?

piglit/tests/glslparsertest/glsl2/fdo100438.frag
Comment 3 Paul Menzel 2017-08-16 15:44:17 UTC
This seems to be fixed?

The test reveals a regression(?) too, cf bug 102265 [1]. So thank you for adding the test.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=102265
Comment 4 Timothy Arceri 2017-08-16 23:58:30 UTC
*** Bug 102265 has been marked as a duplicate of this bug. ***
Comment 5 Timothy Arceri 2017-11-20 00:07:35 UTC
Fixed by:

Author: George Barrett <bob@bob131.so>
Date:   Sun Nov 19 21:55:10 2017 +1100

    glsl: Catch subscripted calls to undeclared subroutines
    
    generate_array_index fails to check whether the target of a subroutine
    call exists in the AST, potentially passing around null ir_rvalue
    pointers eventuating in abort/segfault.
    
    Fixes: fd01840c0bd3 ("glsl: add AoA support to subroutines")
    Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100438


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.