Bug 104359 - Mesa freezes in "vtn_cfg_walk_blocks" with Sacha Willems' hdr, parallaxmapping and specializationconstants Vulkan demos
Summary: Mesa freezes in "vtn_cfg_walk_blocks" with Sacha Willems' hdr, parallaxmappin...
Status: VERIFIED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Juan A. Suarez
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-21 12:57 UTC by Eero Tamminen
Modified: 2017-12-29 09:52 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Fix for the hang (don't continue without incrementing the loop counter) (1.42 KB, patch)
2017-12-22 11:07 UTC, Eero Tamminen
Details | Splinter Review

Description Eero Tamminen 2017-12-21 12:57:41 UTC
Latest Mesa git version freezes at start of Sacha Willems' HDR, parallaxmapping, and specializationconstants demos, which worked fine earlier.  Mesa spends now all of its time in the "vtn_cfg_walk_blocks" function.

Gdb gives following backtrace:
--------------------------------
(gdb) bt
#0  0x00007f19e2eb1c7a in vtn_cfg_walk_blocks (b=b@entry=0x18fdaf0, cf_list=cf_list@entry=0x19098c8, start=<optimized out>, switch_case=switch_case@entry=0x0, 
    switch_break=switch_break@entry=0x0, loop_break=loop_break@entry=0x0, loop_cont=0x0, end=0x0) at ../../../src/compiler/spirv/vtn_cfg.c:552
#1  0x00007f19e2eb54d4 in vtn_build_cfg (b=b@entry=0x18fdaf0, words=words@entry=0x18fc4e4, end=end@entry=0x18fcdd4) at ../../../src/compiler/spirv/vtn_cfg.c:600
#2  0x00007f19e2ea8371 in spirv_to_nir (words=0x18fc4e4, words@entry=0x18fbf48, word_count=931, spec=spec@entry=0x183d9f0, num_spec=num_spec@entry=1, 
    stage=stage@entry=MESA_SHADER_VERTEX, entry_point_name=<optimized out>, options=0x7ffc34c10910, nir_options=0x7f19e2ef9000 <scalar_nir_options>)
    at ../../../src/compiler/spirv/spirv_to_nir.c:3746
#3  0x00007f19e2b03a55 in anv_shader_compile_to_nir (pipeline=0x18fcde0, pipeline=0x18fcde0, spec_info=0x7ffc34c10a90, stage=MESA_SHADER_VERTEX, 
    entrypoint_name=0x18fcde0 "P\371\214\001", module=0x18fbf30, mem_ctx=0x1840de0) at ../../../src/intel/vulkan/anv_pipeline.c:149
#4  anv_pipeline_compile (pipeline=pipeline@entry=0x18fcde0, mem_ctx=mem_ctx@entry=0x1840de0, module=module@entry=0x18fbf30, 
    entrypoint=entrypoint@entry=0x4ab982 "main", stage=stage@entry=MESA_SHADER_VERTEX, spec_info=spec_info@entry=0x7ffc34c14850, prog_data=0x7ffc34c10a90, 
    map=0x7ffc34c109b0) at ../../../src/intel/vulkan/anv_pipeline.c:395

(gdb) info locals
case_block = 0x1994470
w = <optimized out>
break_block = 0x1994470
swtch = 0x1994500
branch_end = <optimized out>
is_default = <optimized out>
branch_type = <optimized out>
block = <optimized out>

(gdb) print *b
$1 = {nb = {cursor = {option = nir_cursor_before_block, {block = 0x1993ce0, instr = 0x1993ce0}}, exact = false, shader = 0x0, impl = 0x0}, fail_jump = {{
      __jmpbuf = {4897154, 1860650571846527914, 26201568, 140721193552528, 26197832, 26197832, -1861620158216655958, -1737934244285240406}, 
      __mask_was_saved = 0, __saved_mask = {__val = {0 <repeats 16 times>}}}}, spirv = 0x18fbf48, shader = 0x190c5c0, options = 0x7ffc34c10910, block = 0x0, 
  spirv_offset = 0, file = 0x0, line = -1, col = -1, const_table = 0x0, phi_table = 0x0, num_specializations = 1, specializations = 0x183d9f0, 
  value_id_bound = 144, values = 0x19ae230, entry_point_stage = MESA_SHADER_VERTEX, entry_point_name = 0x4ab982 "main", entry_point = 0x19ae2d0, 
  origin_upper_left = false, pixel_center_integer = false, func = 0x0, functions = {head_sentinel = {next = 0x19098a0, prev = 0x0}, tail_sentinel = {next = 0x0, 
      prev = 0x19098a0}}, func_param_idx = 0, has_loop_continue = false}
--------------------------------
Comment 1 Eero Tamminen 2017-12-21 13:48:30 UTC
Manual bisect gave following commit as culprit:
-----------------------------------------------
commit 9702fac68e8bd07be8871f7925d7f9fb98da3699
Author:     Juan A. Suarez Romero <jasuarez@igalia.com>
AuthorDate: Tue Dec 19 17:55:24 2017 +0000
Commit:     Juan A. Suarez Romero <jasuarez@igalia.com>
CommitDate: Wed Dec 20 10:39:15 2017 +0100

    spirv: consider bitsize when handling OpSwitch cases
    
    When walking over all the cases in a OpSwitch, take in account the bitsize
    of the literals to avoid getting wrong cases.
    
    Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
-----------------------------------------------

I sent a fix for it to mesa-dev:
https://patchwork.freedesktop.org/patch/194610/
Comment 2 Ian Romanick 2017-12-21 19:58:53 UTC
There's nothing in the CTS or crucible that reproduces this bug?  We really should add something.
Comment 3 Eero Tamminen 2017-12-22 11:07:05 UTC
Created attachment 136365 [details] [review]
Fix for the hang (don't continue without incrementing the loop counter)

According to Mark, commit 9702fac68e8bd07be8871f7925d7f9fb98da3699 hangs vulkancts and crucible on all platforms.
Comment 4 Jason Ekstrand 2017-12-28 18:42:29 UTC
I've pushed a revert of Mark's revert squashed together with Eero's patch:

commit 5c5f2eaa08fb6c1b1241c424dd4b33d326a15b7d
Author: Eero Tamminen <eero.t.tamminen@intel.com>
Date:   Tue Dec 26 07:21:21 2017 -0800

    spirv: consider bitsize when handling OpSwitch cases
    
    This reverts commit 7665383a33f9ce9256aa121cbe4d3bd948dff145 and is
    squashed together with https://patchwork.freedesktop.org/patch/194610/
    (spirv: avoid infinite loop / freeze in vtn_cfg_walk_blocks()) which
    fixes https://bugs.freedesktop.org/show_bug.cgi?id=104359 properly.
    
    Fixes: 9702fac68e (spirv: consider bitsize when handling OpSwitch cases)
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104359
    Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
    Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Comment 5 Eero Tamminen 2017-12-29 09:52:39 UTC
Verified.  Thanks for the squash & push!

(My new-year resolution is to never again to mess Mesa patch sending like I did with this.)


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.