Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

ICE when using nalgebra Matrix3 in rust-cuda kernel: "failed to parse bitcode for LTO module"

Abierto
#222 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
rust
Área
compilers

Línea de trabajo

Reproduce el fallo de my-kernel/src/lib.rs con la toolchain nightly indicada y la configuración de rust-cuda 0.3.0. Inspecciona build.rs alrededor de la línea 15, donde se hace unwrap de BuildFailed, y revisa el archivo adjunto rustc-ice-2025-05-29T12_03_44-26464.txt junto con el error de bitcode/LTO. Se considera terminado cuando el kernel Matrix3 ya no provoca un ICE del compilador.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

I tried writing this (obviously wrong) matrix multiplication kernel with nalgebra:

#![allow(improper_ctypes_definitions, clippy::missing_safety_doc)]

use cuda_std::prelude::*;
use cuda_std::vek::Vec2;
use nalgebra::Matrix3;

#[kernel]
pub unsafe fn matmul(a: &Matrix3<u8>, b: &Matrix3<u8>, c: *mut Matrix3<u8>) {
    let Vec2 { x, y } = thread::index_2d();
    let x = x as usize;
    let y = y as usize;
    (*c)[(x, y)] = (a.row(x) * b.column(y)).sum();
}

But then the codegen throws an ICE:

   Compiling gpu-playground v0.1.0 (F:\rust\gpu-playground2)
error: failed to run custom build command for `gpu-playground v0.1.0 (F:\rust\gpu-playground2)`

Caused by:
  process didn't exit successfully: `F:\rust\gpu-playground2\target\debug\build\gpu-playground-6476c9a6924a5773\build-script-build` (exit code: 101)
  --- stdout
  cargo::rerun-if-changed=build.rs
  cargo::rerun-if-changed=my-kernel
  cargo:rerun-if-changed=F:\rust\gpu-playground2\my-kernel

  --- stderr
     Compiling my-kernel v0.1.0 (F:\rust\gpu-playground2\my-kernel)
  warning[E0133]: dereference of raw pointer is unsafe and requires unsafe block
    --> src\lib.rs:12:5
     |
  12 |     (*c)[(x, y)] = (a.row(x) * b.column(y)).sum();
     |     ^^^^ dereference of raw pointer
     |
     = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>
     = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
  note: an unsafe function restricts its caller, but its body is safe by default
    --> src\lib.rs:8:1
     |
  8  | pub unsafe fn matmul(a: &Matrix3<u8>, b: &Matrix3<u8>, c: *mut Matrix3<u8>) {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     = note: `#[warn(unsafe_op_in_unsafe_fn)]` on by default

  error: failed to parse bitcode for LTO module: Explicit gep type does not match pointee type of pointer operand (Producer: 'LLVM7.1.0' Reader: 'LLVM 7.1.0')


  thread 'coordinator' panicked at C:\Users\steve\scoop\persist\rustup\.rustup\toolchains\nightly-2025-03-02-x86_64-pc-windows-msvc\lib/rustlib/src/rust\compiler\rustc_codegen_ssa\src\back\write.rs:1686:29:
  C:\Users\steve\scoop\persist\rustup\.rustup\toolchains\nightly-2025-03-02-x86_64-pc-windows-msvc\lib/rustlib/src/rust\compiler\rustc_codegen_ssa\src\back\write.rs:1686:29: worker thread panicked
  stack backtrace:
     0:     0x7ffdb516f403 - std::backtrace_rs::backtrace::win64::trace
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
     1:     0x7ffdb516f403 - std::backtrace_rs::backtrace::trace_unsynchronized
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
     2:     0x7ffdb516f403 - std::sys::backtrace::_print_fmt
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\sys\backtrace.rs:66
     3:     0x7ffdb516f403 - std::sys::backtrace::impl$0::print::impl$0::fmt
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\sys\backtrace.rs:39
     4:     0x7ffdb51a246a - core::fmt::rt::Argument::fmt
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\core\src\fmt\rt.rs:177
     5:     0x7ffdb51a246a - core::fmt::write
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\core\src\fmt\mod.rs:1449
     6:     0x7ffdb51653a7 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\io\mod.rs:1890
     7:     0x7ffdb516f245 - std::sys::backtrace::BacktraceLock::print
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\sys\backtrace.rs:42
     8:     0x7ffdb51735b9 - std::panicking::default_hook::closure$0
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\panicking.rs:298
     9:     0x7ffdb51733a8 - std::panicking::default_hook
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\panicking.rs:325
    10:     0x7ffdb66edc57 - core[840dbb2f2845c865]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[82a80524e948e0f0]::Level, &str), usize), <((rustc_lint_defs[82a80524e948e0f0]::Level, &str), usize) as core[840dbb2f2845c865]::cmp::PartialOrd>::lt>
    11:     0x7ffdb66edc57 - core[840dbb2f2845c865]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[82a80524e948e0f0]::Level, &str), usize), <((rustc_lint_defs[82a80524e948e0f0]::Level, &str), usize) as core[840dbb2f2845c865]::cmp::PartialOrd>::lt>
    12:     0x7ffdb517424e - alloc::boxed::impl$30::call
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\alloc\src\boxed.rs:1986
    13:     0x7ffdb517424e - std::panicking::rust_panic_with_hook
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\panicking.rs:839
    14:     0x7ffdb7c6850f - <rustc_data_structures[da05d66f39f5cffa]::profiling::SelfProfilerRef>::exec::cold_call::<<rustc_data_structures[da05d66f39f5cffa]::profiling::SelfProfilerRef>::incr_result_hashing::{closure#0}>
    15:     0x7ffdb7c62299 - std[47ca72d4d3ff77e3]::sys::backtrace::__rust_end_short_backtrace::<std[47ca72d4d3ff77e3]::panicking::begin_panic<alloc[3445c4d0d5195b57]::string::String>::{closure#0}, !>
    16:     0x7ffdb7c5ddf9 - std[47ca72d4d3ff77e3]::panicking::begin_panic::<alloc[3445c4d0d5195b57]::string::String>
    17:     0x7ffdb7cf7546 - rustc_middle[1aca9e23c1f5e2ca]::util::bug::span_bug_fmt::<rustc_span[f932d894d049cea0]::span_encoding::Span>
    18:     0x7ffdb7cd80dd - <rustc_middle[1aca9e23c1f5e2ca]::ty::consts::Const>::to_value
    19:     0x7ffdb7cd7eb6 - <rustc_middle[1aca9e23c1f5e2ca]::ty::consts::Const>::to_value
    20:     0x7ffdb7cf7432 - rustc_middle[1aca9e23c1f5e2ca]::util::bug::bug_fmt
    21:     0x7ffdbdf4bef0 - rustc_codegen_ssa::back::write::start_executing_work::{{closure}}::hd8445bdf0e67cb18
    22:     0x7ffdbdea6701 - std::sys::backtrace::__rust_begin_short_backtrace::hfdfd38ba62b7d4c5
    23:     0x7ffdbdf6ef1a - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::hcfe036d37e2b909f
    24:     0x7ffdbdf81210 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hdf11f69de5923ea6
    25:     0x7ffdbdda4e91 - std::panicking::try::do_call::h13938fb4f3c25359
    26:     0x7ffdbdf7fac3 - hashbrown::raw_entry::RawEntryBuilderMut<K,V,S,A>::from_key::hc4c6d274dc70f660
    27:     0x7ffdbdf6e51a - std::thread::Builder::spawn_unchecked_::{{closure}}::h2b5e349ba6fba155
    28:     0x7ffdbdf11a29 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::hcf79a037a97f74ed
    29:     0x7ffdb51849ed - alloc::boxed::impl$28::call_once
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\alloc\src\boxed.rs:1972
    30:     0x7ffdb51849ed - alloc::boxed::impl$28::call_once
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\alloc\src\boxed.rs:1972
    31:     0x7ffdb51849ed - std::sys::pal::windows::thread::impl$0::new::thread_start
                                 at /rustc/8c392966a013fd8a09e6b78b3c8d6e442bc278e1/library\std\src\sys\pal\windows\thread.rs:56
    32:     0x7ffe6e37e8d7 - BaseThreadInitThunk
    33:     0x7ffe6f8bc5dc - RtlUserThreadStart

  error: the compiler unexpectedly panicked. this is a bug.

  note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

  note: please make sure that you have updated to the latest nightly

  note: please attach the file at `F:\rust\gpu-playground2\my-kernel\rustc-ice-2025-05-29T12_03_44-26464.txt` to your bug report

  note: compiler flags: --crate-type cdylib --crate-type rlib -C opt-level=3 -C embed-bitcode=no -C strip=debuginfo -Z unstable-options -Z codegen-backend=F:\rust\gpu-playground2\target\debug\rustc_codegen_nvvm.dll -Z crate-attr=feature(register_tool) -Z crate-attr=register_tool(nvvm_internal) -Z crate-attr=no_std -Z saturating_float_casts=false -C llvm-args=-arch=compute_61 --override-libm

  note: some of the compiler flags provided by cargo are hidden

  query stack during panic:
  end of query stack

  error: the compiler unexpectedly panicked. this is a bug.

  note: we would appreciate a bug report: https://github.com/Rust-GPU/Rust-CUDA/issues/new

  note: please make sure that you have updated to the latest nightly

  note: please attach the file at `F:\rust\gpu-playground2\my-kernel\rustc-ice-2025-05-29T12_03_44-26464.txt` to your bug report

  note: compiler flags: --crate-type cdylib --crate-type rlib -C opt-level=3 -C embed-bitcode=no -C strip=debuginfo -Z unstable-options -Z codegen-backend=F:\rust\gpu-playground2\target\debug\rustc_codegen_nvvm.dll -Z crate-attr=feature(register_tool) -Z crate-attr=register_tool(nvvm_internal) -Z crate-attr=no_std -Z saturating_float_casts=false -C llvm-args=-arch=compute_61 --override-libm

  note: some of the compiler flags provided by cargo are hidden

  query stack during panic:
  end of query stack
  note: `rust-cuda` version `0.3.0`

  For more information about this error, try `rustc --explain E0133`.
  warning: `my-kernel` (lib) generated 1 warning
  error: could not compile `my-kernel` (lib) due to 1 previous error; 1 warning emitted

  thread 'main' panicked at build.rs:15:10:
  called `Result::unwrap()` on an `Err` value: BuildFailed
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Lenguaje dominante
Rust
Estrellas
5.4k
Forks
251
Merge medio
4 d 15 h
PR fusionados (30 d)
4

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Rust-GPU/rust-cuda

Todos los issues de Rust-GPU/rust-cuda

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.