Bug 33314

Summary: [glsl] ir_constant_expression.cpp:122: virtual ir_constant* ir_expression::constant_expression_value(): Assertion `op[0]->type->base_type == GLSL_TYPE_BOOL' failed.
Product: Mesa Reporter: Vinson Lee <vlee>
Component: glsl-compilerAssignee: Kenneth Graunke <kenneth>
Status: CLOSED FIXED QA Contact:
Severity: critical    
Priority: medium CC: idr
Version: git   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Vinson Lee 2011-01-20 17:14:32 UTC
mesa: 2fb0aebd4a248d2a0725099cd5646253c30c1dc3 (master)

This fragment shader triggers an assertion in the Mesa GLSL compiler.

void A(int a) {
}

void main()
{
   A(!0);

   gl_FragColor = vec4(0.0);
}


ir_constant_expression.cpp:122: virtual ir_constant* ir_expression::constant_expression_value(): Assertion `op[0]->type->base_type == GLSL_TYPE_BOOL' failed.

(gdb) bt
#0  0x007d0416 in __kernel_vsyscall ()
#1  0x00918941 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0x0091be42 in abort () at abort.c:92
#3  0x009118e8 in __assert_fail (assertion=0x4656b0 "op[0]->type->base_type == GLSL_TYPE_BOOL", file=0x465600 "ir_constant_expression.cpp", line=122, 
    function=0x465d80 "virtual ir_constant* ir_expression::constant_expression_value()") at assert.c:81
#4  0x002a6b0a in ir_expression::constant_expression_value (this=0x904aff0) at ir_constant_expression.cpp:122
#5  0x003792d1 in process_parameters (instructions=0x9257b08, actual_parameters=0xbf9b9564, parameters=0x8f8038c, state=0x8f76108) at ast_function.cpp:48
#6  0x0037cab5 in ast_function_expression::hir (this=0x8f80360, instructions=0x9257b08, state=0x8f76108) at ast_function.cpp:1198
#7  0x00285be2 in ast_expression_statement::hir (this=0x8f804b0, instructions=0x9257b08, state=0x8f76108) at ast_to_hir.cpp:1701
#8  0x00285c42 in ast_compound_statement::hir (this=0x8f807c0, instructions=0x9257b08, state=0x8f76108) at ast_to_hir.cpp:1717
#9  0x002884b5 in ast_function_definition::hir (this=0x8f80288, instructions=0x8f7f198, state=0x8f76108) at ast_to_hir.cpp:2971
#10 0x00281287 in _mesa_ast_to_hir (instructions=0x8f7f198, state=0x8f76108) at ast_to_hir.cpp:85
#11 0x0027faae in _mesa_glsl_compile_shader (ctx=0x8f0a628, shader=0x8f75ff8) at program/ir_to_mesa.cpp:3109
#12 0x0022193c in compile_shader (ctx=0x8f0a628, shaderObj=1) at main/shaderapi.c:856
#13 0x0022228f in _mesa_CompileShaderARB (shaderObj=1) at main/shaderapi.c:1187

(gdb) frame 4
#4  0x002a6b0a in ir_expression::constant_expression_value (this=0x904aff0) at ir_constant_expression.cpp:122
122	      assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
(gdb) print op[0]->type->base_type
$1 = GLSL_TYPE_INT
(gdb) l
117	           assert(0);
118	       }
119	       break;
120	
121	   case ir_unop_logic_not:
122	      assert(op[0]->type->base_type == GLSL_TYPE_BOOL);
123	      for (unsigned c = 0; c < op[0]->type->components(); c++)
124		 data.b[c] = !op[0]->value.b[c];
125	      break;
126
Comment 1 Eric Anholt 2011-04-13 18:09:27 UTC
commit 01822706ec2c2501a2cd2431a90c56b334b79a5c
Author: Eric Anholt <eric@anholt.net>
Date:   Sat Apr 9 15:59:20 2011 -1000

    glsl: Avoid cascading errors when looking for a scalar boolean and failing.
    
    By always using a boolean, we should generally avoid further
    complaints.  The failure case I see is logic_not, where the user might
    understandably make the mistake of using `!' on a boolean vector (like
    a piglit case did recently!), and then get a further complaint that
    the new boolean type doesn't match the bvec it gets assigned to.
    
    Fixes invalid-logic-not-06.vert (assertion failure when the bad type
    ends up in an expression and ir_constant_expression gets angry).
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=33314
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Comment 2 Vinson Lee 2011-04-13 20:06:56 UTC
mesa: a9a02c8a39620515ec9fd0d774ce329cf67ecb4e (master)

Verified fixed.

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.