[Migrated] SPIR-T panics with assertion failed: list_eq_key(children) ==\n list_eq_key(self.func_def_body.at(unstructured_region).def().children).
まだ誰も着手していません。
- 主要言語
- Rust
- スター
- 3.4k
- フォーク
- 126
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1086
Old labels: t: bug
Originally creatd by schell on 2023-07-28T01:00:19Z
While debugging an issue with nested loops I simplified my shader to one loop as a sanity check and then hit this compiler panic. It seems to be caused by looping indefinitely (in my shader I forgot to increment a value used in the break condition).
Expected Behaviour
Compiler should error instead of panic.
Actual Behavior
Compiler panics with:
thread 'rustc' panicked at 'assertion failed: list_eq_key(children) ==\n list_eq_key(self.func_def_body.at(unstructured_region).def().children)',
/Users/schell/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spirt-0.2.0/src/cfg.rs:1214:13
Example & Steps To Reproduce
Compile this shader:
use glam::{Vec3, Vec4, Vec4Swizzles, Vec3Swizzles};
use spirv_std::{image::Cubemap, Sampler, spirv};
#[cfg(target_arch = "spirv")]
use spirv_std::num_traits::Float;
#[spirv(fragment)]
pub fn fragment_convolve_diffuse_irradiance(
environment_texture: &Cubemap,
sampler: &Sampler,
local_pos: Vec3,
frag_color: &mut Vec4,
) {
let pi: f32 = 3.1415927;
let normal = local_pos.normalize_or_zero();
let mut irradiance = Vec3::new(0.0, 0.0, 0.0);
let right = Vec3::new(0.0, 1.0, 0.0).cross(normal).normalize_or_zero();
let up = normal.cross(right).normalize_or_zero();
let nr_samples = 0.0;
irradiance += environment_texture.sample(*sampler, up).xyz();
loop {
if nr_samples > 2.0 {
break;
}
irradiance += environment_texture.sample(*sampler, up).xyz();
}
let color = irradiance * (pi / nr_samples);
*frag_color = color.xyz().extend(1.0);
}
System Info
note: rustc 1.70.0-nightly (84dd17b56 2023-04-14) running on aarch64-apple-darwin
note: compiler flags: --crate-type dylib -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 -Z unstable-options -Z codegen-backend=/Users/schell/code/renderling/shaders/target/release/librustc_codegen_spirv.dylib -Z binary-dep-depinfo -C symbol-mangling-version=v0 -Z crate-attr=feature(register_tool) -Z crate-attr=register_tool(rust_gpu) -C llvm-args=--module-output=multiple
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
note: rust-gpu version 0.8.0
- Rust: [e.g. 1.49.0-nightly (1eaadebb3 2020-10-21)]
- OS: [e.g. macOS 10.15.7]
- GPU: [e.g. Intel(R) UHD Graphics 630]
- SPIR-V: [e.g. v2020.3 unknown hash, 2020-06-12T01:06:18]
Backtrace
Backtrace
stack backtrace:
0: 0x102eb5894 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hec12b20601f2bdf0
1: 0x102f089a0 - core::fmt::write::h84e52a09c8a95be7
2: 0x102eab344 - std::io::Write::write_fmt::h694b0891aa3b64d5
3: 0x102eb56a8 - std::sys_common::backtrace::print::hdefc03f01b0d83f1
4: 0x102eb80bc - std::panicking::default_hook::{{closure}}::hc4c0bdc7bd459aa9
5: 0x102eb7e7c - std::panicking::default_hook::h6dc5d3ac0202ebe6
6: 0x10470d6f4 - rustc_codegen_spirv::__rustc_codegen_backend::{{closure}}::h6edd25957ff152e7
7: 0x102eb877c - std::panicking::rust_panic_with_hook::h04718b2e9bd107f5
8: 0x102eb8534 - std::panicking::begin_panic_handler::{{closure}}::h1c251c8e7c7e5969
9: 0x102eb5cb4 - std::sys_common::backtrace::__rust_end_short_backtrace::hc2f6697e294cde53
10: 0x102eb8308 - _rust_begin_unwind
11: 0x102f34420 - core::panicking::panic_fmt::hcabee496664f2172
12: 0x102f34490 - core::panicking::panic::hc56ef5c96c7e745b
13: 0x1049027e8 - spirt::cfg::Structurizer::structurize_func::h8ccbca14134c4bed
14: 0x10488ac74 - spirt::passes::legalize::structurize_func_cfgs::h5a9bb2f8c14010b3
15: 0x1046b6974 - rustc_codegen_spirv::linker::link::h666c87acc0f36829
16: 0x10465bae0 - rustc_codegen_spirv::link::link::h87c14272e01e3168
17: 0x10470bf54 - <rustc_codegen_spirv::SpirvCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::link::ha3f63258b51407e5
18: 0x10b47f7f8 - <rustc_interface[b2f1c94be2f1d7cc]::queries::Linker>::link
19: 0x10b3b3da4 - rustc_span[dc18a910ba5122f1]::set_source_map::<core[723a1ab69fb7b501]::result::Result<(), rustc_span[dc18a910ba5122f1]::ErrorGuaranteed>, rustc_interface[b2f1c94be2f1d7cc]::interface::run_compiler<core[723a1ab69fb7b501]::result::Result<(), rustc_span[dc18a910ba5122f1]::ErrorGuaranteed>, rustc_driver_impl[27bd541b75fbd8b5]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
20: 0x10b3c7184 - std[b04369226ecd3a5b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b2f1c94be2f1d7cc]::util::run_in_thread_pool_with_globals<rustc_interface[b2f1c94be2f1d7cc]::interface::run_compiler<core[723a1ab69fb7b501]::result::Result<(), rustc_span[dc18a910ba5122f1]::ErrorGuaranteed>, rustc_driver_impl[27bd541b75fbd8b5]::run_compiler::{closure#1}>::{closure#0}, core[723a1ab69fb7b501]::result::Result<(), rustc_span[dc18a910ba5122f1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[723a1ab69fb7b501]::result::Result<(), rustc_span[dc18a910ba5122f1]::ErrorGuaranteed>>
21: 0x10b3b8364 - <<std[b04369226ecd3a5b]::thread::Builder>::spawn_unchecked_<rustc_interface[b2f1c94be2f1d7cc]::util::run_in_thread_pool_with_globals<rustc_interface[b2f1c94be2f1d7cc]::interface::run_compiler<core[723a1ab69fb7b501]::result::Result<(), rustc_span[dc18a910ba5122f1]::ErrorGuaranteed>, rustc_driver_impl[27bd541b75fbd8b5]::run_compiler::{closure#1}>::{closure#0}, core[723a1ab69fb7b501]::result::Result<(), rustc_span[dc18a910ba5122f1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[723a1ab69fb7b501]::result::Result<(), rustc_span[dc18a910ba5122f1]::ErrorGuaranteed>>::{closure#1} as core[723a1ab69fb7b501]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
22: 0x102ec0e24 - std::sys::unix::thread::Thread::new::thread_start::h5343322b5f9311e3
23: 0x18df97fa8 - __pthread_joiner_wake
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
報告された rustc と rust-gpu のセットアップでシェーダーを再現することから始め、次に SPIR-T の spirt::cfg::Structurizer::structurize_func を cfg.rs:1214 で調べ、周辺の structurize_func_cfgs パスも確認します。完了条件は、この終了しないループが list_eq_key アサーションの panic ではなくコンパイラーエラーを生成することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100