Bug 33308

Summary: [glsl] ast_to_hir.cpp:3016: virtual ir_rvalue* ast_jump_statement::hir(exec_list*, _mesa_glsl_parse_state*): Assertion `ret != __null' failed.
Product: Mesa Reporter: Vinson Lee <vlee>
Component: glsl-compilerAssignee: Ian Romanick <idr>
Status: CLOSED FIXED QA Contact:
Severity: critical    
Priority: medium    
Version: 7.10   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Vinson Lee 2011-01-20 15:37:19 UTC
mesa: 2fb0aebd4a248d2a0725099cd5646253c30c1dc3 (master)

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

void A() {
}

void B() {
   return A();
}

void main() {
   gl_FragColor = vec4(0.0);
}


ast_to_hir.cpp:3016: virtual ir_rvalue* ast_jump_statement::hir(exec_list*, _mesa_glsl_parse_state*): Assertion `ret != __null' failed.

(gdb) bt
#0  0x00cbb416 in __kernel_vsyscall ()
#1  0x009b5941 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0x009b8e42 in abort () at abort.c:92
#3  0x009ae8e8 in __assert_fail (assertion=0x589007 "ret != __null", file=0x5877aa "ast_to_hir.cpp", line=3016, 
    function=0x589400 "virtual ir_rvalue* ast_jump_statement::hir(exec_list*, _mesa_glsl_parse_state*)") at assert.c:81
#4  0x003b76bf in ast_jump_statement::hir (this=0x83781c8, instructions=0x864fb20, state=0x836e110) at ast_to_hir.cpp:3016
#5  0x003b4c42 in ast_compound_statement::hir (this=0x8378220, instructions=0x864fb20, state=0x836e110) at ast_to_hir.cpp:1717
#6  0x003b74b5 in ast_function_definition::hir (this=0x8378360, instructions=0x8377450, state=0x836e110) at ast_to_hir.cpp:2971
#7  0x003b0287 in _mesa_ast_to_hir (instructions=0x8377450, state=0x836e110) at ast_to_hir.cpp:85
#8  0x003aeaae in _mesa_glsl_compile_shader (ctx=0x8302628, shader=0x836dff8) at program/ir_to_mesa.cpp:3109
#9  0x0035093c in compile_shader (ctx=0x8302628, shaderObj=1) at main/shaderapi.c:856
#10 0x0035128f in _mesa_CompileShaderARB (shaderObj=1) at main/shaderapi.c:1187

(gdb) frame 4
#4  0x003b76bf in ast_jump_statement::hir (this=0x83781c8, instructions=0x864fb20, state=0x836e110) at ast_to_hir.cpp:3016
3016		 assert(ret != NULL);
(gdb) l
3011				     "returning void",
3012				     state->current_function->function_name());
3013		 }
3014	
3015		 ir_rvalue *const ret = opt_return_value->hir(instructions, state);
3016		 assert(ret != NULL);
3017	
3018		 /* Implicit conversions are not allowed for return values. */
3019		 if (state->current_function->return_type != ret->type) {
3020		    YYLTYPE loc = this->get_location();
(gdb) print ret
$1 = (ir_rvalue * const) 0x0
Comment 1 Ian Romanick 2011-01-22 18:18:49 UTC
This should be fixed on master by the following commit.  It will be cherry-picked over to 7.9 and 7.10 in the next week or so.

commit 2db46fe5f0145a6afff5b8edc2f00b8c734bb640
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Sat Jan 22 17:47:05 2011 -0800

    glsl: Don't assert when the value returned by a function has no rvalue
    
    The rvalue of the returned value can be NULL if the shader says
    'return foo();' and foo() is a function that returns void.
    
    Existing GLSL specs do *NOT* say that this is an error.  The type of
    the return value is void.  If the return type of the function is also
    void, then this should compile without error.  I expect that future
    versions of the GLSL spec will fix this (wink, wink, nudge, nudge).
    
    Fixes piglit test glsl-1.10/compiler/expressions/return-01.vert and
    bugzilla #33308.
    
    NOTE: This is a candidate for the 7.9 and 7.10 branches.
Comment 2 Ian Romanick 2011-02-04 16:55:02 UTC
Fixed by 1f34edbb (7.9) and b51b8db4 (7.10).
Comment 3 Vinson Lee 2011-03-26 16:43:27 UTC
mesa: 56ef62d9885f805bbfb2243dc860ff425d5b4d3b (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.