Bug 85252

Summary: Segfault in compiler while processing ternary operator with void arguments
Product: Mesa Reporter: Ian Romanick <idr>
Component: glsl-compilerAssignee: Ian Romanick <idr>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: siglesias
Version: git   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Test case

Description Ian Romanick 2014-10-20 17:58:53 UTC
Created attachment 108126 [details]
Test case

The attached test (also sent to the piglit list) segfaults in ast_to_hir.  gdb output below.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff3c429b3 in ast_expression::do_hir (this=0xae4738, 
    instructions=0xa4dc80, state=0xab6ef8, needs_rvalue=<optimized out>)
    at ../../src/glsl/ast_to_hir.cpp:1574
1574	      if ((!apply_implicit_conversion(op[1]->type, op[2], state)
Missing separate debuginfos, use: debuginfo-install expat-2.1.0-4.fc18.x86_64 glibc-2.16-34.fc18.x86_64 libgcc-4.7.2-8.fc18.x86_64 libstdc++-4.7.2-8.fc18.x86_64 mesa-libGLU-9.0.0-1.fc18.x86_64 systemd-libs-201-2.fc18.9.x86_64
(gdb) bt
#0  0x00007ffff3c429b3 in ast_expression::do_hir (this=0xae4738, 
    instructions=0xa4dc80, state=0xab6ef8, needs_rvalue=<optimized out>)
    at ../../src/glsl/ast_to_hir.cpp:1574
#1  0x00007ffff3c44663 in ast_expression_statement::hir (this=<optimized out>, 
    instructions=<optimized out>, state=<optimized out>)
    at ../../src/glsl/ast_to_hir.cpp:1829
#2  0x00007ffff3c446af in ast_compound_statement::hir (this=0xae4858, 
    instructions=0xa4dc80, state=0xab6ef8)
    at ../../src/glsl/ast_to_hir.cpp:1845
#3  0x00007ffff3c46a61 in ast_function_definition::hir (this=0xae48d8, 
    instructions=<optimized out>, state=0xab6ef8)
    at ../../src/glsl/ast_to_hir.cpp:4239
#4  0x00007ffff3c414c0 in _mesa_ast_to_hir (instructions=0xa9cd78, 
    state=0xab6ef8) at ../../src/glsl/ast_to_hir.cpp:100
#5  0x00007ffff3c97ffb in _mesa_glsl_compile_shader (
    ctx=ctx@entry=0x7ffff3963038, shader=shader@entry=0xa9d5e8, 
    dump_ast=dump_ast@entry=false, dump_hir=dump_hir@entry=false)
    at ../../src/glsl/glsl_parser_extras.cpp:1465
#6  0x00007ffff3af7fcc in compile_shader (ctx=0x7ffff3963038, 
    shaderObj=<optimized out>) at ../../src/mesa/main/shaderapi.c:852
#7  0x00007ffff7cfc75f in stub_glCompileShader (shader=1)
    at tests/util/piglit-dispatch-gen.c:6375
#8  0x0000000000405598 in compile_glsl (target=35633)
    at tests/shaders/shader_runner.c:326
#9  0x00000000004061b7 in leave_state (state=vertex_shader, 
    line=0xaa4840 "[fragment shader]\n\nvarying vec4 c;\nuniform bool b;\n\nvoid good(void)\n{\n    gl_FragColor = c;\n}\n\nvoid bad(void)\n{\n    gl_FragColor = c + vec4(0, 0, 1, 0);\n}\n\nvoid main()\n{\n    b ? good() : bad();\n}\n\n[te"...) at tests/shaders/shader_runner.c:706
#10 0x00000000004067f9 in process_test_script (
    script_name=0x7fffffffe25c "tests/spec/glsl-1.10/execution/void-ternary.shader_test") at tests/shaders/shader_runner.c:900
#11 0x000000000040b2a9 in piglit_init (argc=2, argv=0x7fffffffded8)
    at tests/shaders/shader_runner.c:2685
#12 0x00007ffff7d87224 in run_test (gl_fw=0x612010, argc=2, 
    argv=0x7fffffffded8)
    at tests/util/piglit-framework-gl/piglit_winsys_framework.c:72
#13 0x00007ffff7d6c86b in piglit_gl_test_run (argc=2, argv=0x7fffffffded8, 
    config=0x7fffffffdda0) at tests/util/piglit-framework-gl.c:151
#14 0x0000000000404ef2 in main (argc=2, argv=0x7fffffffded8)
    at tests/shaders/shader_runner.c:60
Comment 1 Renaud Gaubert 2015-07-07 20:31:23 UTC
(In reply to Ian Romanick from comment #0)
> Created attachment 108126 [details]
> Test case
> 
> The attached test (also sent to the piglit list) segfaults in ast_to_hir. 
> gdb output below.
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff3c429b3 in ast_expression::do_hir (this=0xae4738, 
>     instructions=0xa4dc80, state=0xab6ef8, needs_rvalue=<optimized out>)
>     at ../../src/glsl/ast_to_hir.cpp:1574
> 1574	      if ((!apply_implicit_conversion(op[1]->type, op[2], state)
> Missing separate debuginfos, use: debuginfo-install
> expat-2.1.0-4.fc18.x86_64 glibc-2.16-34.fc18.x86_64
> libgcc-4.7.2-8.fc18.x86_64 libstdc++-4.7.2-8.fc18.x86_64
> mesa-libGLU-9.0.0-1.fc18.x86_64 systemd-libs-201-2.fc18.9.x86_64
> (gdb) bt
> #0  0x00007ffff3c429b3 in ast_expression::do_hir (this=0xae4738, 
>     instructions=0xa4dc80, state=0xab6ef8, needs_rvalue=<optimized out>)
>     at ../../src/glsl/ast_to_hir.cpp:1574
> #1  0x00007ffff3c44663 in ast_expression_statement::hir (this=<optimized
> out>, 
>     instructions=<optimized out>, state=<optimized out>)
>     at ../../src/glsl/ast_to_hir.cpp:1829
> #2  0x00007ffff3c446af in ast_compound_statement::hir (this=0xae4858, 
>     instructions=0xa4dc80, state=0xab6ef8)
>     at ../../src/glsl/ast_to_hir.cpp:1845
> #3  0x00007ffff3c46a61 in ast_function_definition::hir (this=0xae48d8, 
>     instructions=<optimized out>, state=0xab6ef8)
>     at ../../src/glsl/ast_to_hir.cpp:4239
> #4  0x00007ffff3c414c0 in _mesa_ast_to_hir (instructions=0xa9cd78, 
>     state=0xab6ef8) at ../../src/glsl/ast_to_hir.cpp:100
> #5  0x00007ffff3c97ffb in _mesa_glsl_compile_shader (
>     ctx=ctx@entry=0x7ffff3963038, shader=shader@entry=0xa9d5e8, 
>     dump_ast=dump_ast@entry=false, dump_hir=dump_hir@entry=false)
>     at ../../src/glsl/glsl_parser_extras.cpp:1465
> #6  0x00007ffff3af7fcc in compile_shader (ctx=0x7ffff3963038, 
>     shaderObj=<optimized out>) at ../../src/mesa/main/shaderapi.c:852
> #7  0x00007ffff7cfc75f in stub_glCompileShader (shader=1)
>     at tests/util/piglit-dispatch-gen.c:6375
> #8  0x0000000000405598 in compile_glsl (target=35633)
>     at tests/shaders/shader_runner.c:326
> #9  0x00000000004061b7 in leave_state (state=vertex_shader, 
>     line=0xaa4840 "[fragment shader]\n\nvarying vec4 c;\nuniform bool
> b;\n\nvoid good(void)\n{\n    gl_FragColor = c;\n}\n\nvoid bad(void)\n{\n   
> gl_FragColor = c + vec4(0, 0, 1, 0);\n}\n\nvoid main()\n{\n    b ? good() :
> bad();\n}\n\n[te"...) at tests/shaders/shader_runner.c:706
> #10 0x00000000004067f9 in process_test_script (
>     script_name=0x7fffffffe25c
> "tests/spec/glsl-1.10/execution/void-ternary.shader_test") at
> tests/shaders/shader_runner.c:900
> #11 0x000000000040b2a9 in piglit_init (argc=2, argv=0x7fffffffded8)
>     at tests/shaders/shader_runner.c:2685
> #12 0x00007ffff7d87224 in run_test (gl_fw=0x612010, argc=2, 
>     argv=0x7fffffffded8)
>     at tests/util/piglit-framework-gl/piglit_winsys_framework.c:72
> #13 0x00007ffff7d6c86b in piglit_gl_test_run (argc=2, argv=0x7fffffffded8, 
>     config=0x7fffffffdda0) at tests/util/piglit-framework-gl.c:151
> #14 0x0000000000404ef2 in main (argc=2, argv=0x7fffffffded8)
>     at tests/shaders/shader_runner.c:60

This should be fixed with the following proposed patch on mesa-dev:
http://lists.freedesktop.org/archives/mesa-dev/2015-July/088312.html
Comment 2 Samuel Iglesias Gonsálvez 2015-07-16 06:26:31 UTC
Patch landed.

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.