Rust-GPU / Rust-GPU/rust-gpu

[Migrated] asm reference to non-existent value causes ICE

Open
#132 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.4k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/518
Old labels: t: bug,a: ice,a: error messages,a: asm
Originally creatd by XAMPPRocky on 2021-03-22T07:37:30Z


If you pass a reference to malformed instruction, it will cause the compiler to panic, when it should fail just fail to compile.

Rust
#[spirv(fragment)]
pub fn foo() {
    asm! {
        "%u32 = OpTypeInte 32 0",
        "%zero = OpConstant %u32 0",
}
Error
error: unknown spirv instruction OpTypeInte
  --> /Users/erin.power/src/rust-gpu2/crates/spirv-std/src/arch/barrier.rs:5:5
   |
5  | /     asm! {
6  | |         "%u32 = OpTypeInte 32 0",
7  | |         "%execution = OpConstant %u32 {execution}",
8  | |         // "%memory = OpConstant %u32 {memory}",
...  |
13 | |         // semantics = const SEMANTICS as u8,
14 | |     }
   | |_____^

thread 'rustc' panicked at 'Tried to lookup value that wasn't a type, or has no definition', crates/rustc_codegen_spirv/src/spirv_type.rs:674:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the malformed asm example with the unknown OpTypeInte instruction. Read crates/rustc_codegen_spirv/src/spirv_type.rs around line 674 and trace the lookup reached after the unknown-instruction error. Done means the input fails to compile with an error and no compiler panic or internal compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.