Created attachment 53344 [details] [review] piglit test case mesa: 6f5c73797087c6e7842665f84e41caedea59bb65 (master) A bitwise complement of a boolean triggers a crash in the GLSL compiler. void main() { int x = ~false; } (gdb) bt #0 0x00d59416 in __kernel_vsyscall () #1 0x00925941 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #2 0x00928e42 in abort () at abort.c:92 #3 0x0091e8e8 in __assert_fail (assertion=0x4a9baf "0", file=0x4a9ab6 "ir_constant_expression.cpp", line=138, function=0x4aa280 "virtual ir_constant* ir_expression::constant_expression_value()") at assert.c:81 #4 0x0037fdc6 in ir_expression::constant_expression_value (this=0x98b6e58) at ir_constant_expression.cpp:138 #5 0x00374961 in process_initializer (var=0x98b6ca0, decl=0x972f610, type=0x98af2b8, initializer_instructions=0xbfbaa7a0, state=0x98aecf8) at ast_to_hir.cpp:2370 #6 0x00375748 in ast_declarator_list::hir (this=0x98af628, instructions=0x98b6c60, state=0x98aecf8) at ast_to_hir.cpp:2827 #7 0x0037369c in ast_compound_statement::hir (this=0x98af670, instructions=0x98b6c60, state=0x98aecf8) at ast_to_hir.cpp:1814 #8 0x00376417 in ast_function_definition::hir (this=0x98af3d8, instructions=0x971bed0, state=0x98aecf8) at ast_to_hir.cpp:3269 #9 0x0036ec7d in _mesa_ast_to_hir (instructions=0x971bed0, state=0x98aecf8) at ast_to_hir.cpp:86 #10 0x00351274 in _mesa_glsl_compile_shader (ctx=0x96cf2b0, shader=0x98aeba8) at program/ir_to_mesa.cpp:3439 #11 0x0023b468 in compile_shader (ctx=0x96cf2b0, shaderObj=1) at main/shaderapi.c:731 (gdb) frame 4 #4 0x0037fdc6 in ir_expression::constant_expression_value (this=0x98b6e58) at ir_constant_expression.cpp:138 138 assert(0); (gdb) print op[0]->type->base_type $1 = GLSL_TYPE_BOOL src/glsl/ir_constant_expression.cpp 126 switch (this->operation) { 127 case ir_unop_bit_not: 128 switch (op[0]->type->base_type) { 129 case GLSL_TYPE_INT: 130 for (unsigned c = 0; c < components; c++) 131 data.i[c] = ~ op[0]->value.i[c]; 132 break; 133 case GLSL_TYPE_UINT: 134 for (unsigned c = 0; c < components; c++) 135 data.u[c] = ~ op[0]->value.u[c]; 136 break; 137 default: 138 assert(0); 139 } 140 break;
Does this patch fix the bug for you? http://lists.freedesktop.org/archives/mesa-dev/2011-December/016452.html
Fix by the following commit on master (and commit 7722a54e60c9da080b557d6596e4c9d363ead515 on 7.11): commit 39464489510270bbe472d11f7614c04ce1b6ae33 Author: Ian Romanick <ian.d.romanick@intel.com> Date: Fri Dec 23 17:16:43 2011 -0800 glsl: Don't use base type for bit-not when there's an error Other parts of the compiler assume that expressions will have well-formed types or the error type. Just using the type of the thing being operated on can cause expressions like ~3.14 or ~false to not have a well-formed type. This could then result in an assertion failure in the context epxression handler. If there is an error processing the expression, set the type of the IR expression to error. Fixes piglit's bit-not-0[789].frag tests. NOTE: This is a candidate for the 7.11 branch. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42755 Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Cc: Vinson Lee <vlee@vmware.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.