Closed ZuseZ4 closed 8 months ago
This broke on one of my updates, afaik now every example fails with this Type error. Did something on the Enzyme side change, or do I need to debug from the Rust side?
Can you add the backtrace?
I don't know the right way to get a backtrace in this context, but I updated Enzyme to 3e2de5de6c03b9fe138d657ebfde42fa05af3a4e and rebuilt, attached gdb, and got this.
rustc: /home/jed/src/rust-enzyme/src/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = VectorType; From = Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Thread 4 "coordinator" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe00006c0 (LWP 3770409)]
0x00007ffff36ab32c in ?? () from /usr/lib/libc.so.6
(gdb) bt
#0 0x00007ffff36ab32c in ?? () from /usr/lib/libc.so.6
#1 0x00007ffff365a6c8 in raise () from /usr/lib/libc.so.6
#2 0x00007ffff36424b8 in abort () from /usr/lib/libc.so.6
#3 0x00007ffff36423dc in ?? () from /usr/lib/libc.so.6
#4 0x00007ffff3652d46 in __assert_fail () from /usr/lib/libc.so.6
#5 0x00007fffeba62db7 in LLVMGetElementType () from /home/jed/src/rust-enzyme/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/../lib/libLLVM-17-rust-1.77.0-nightly.so
#6 0x00007ffff42c97b4 in <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::write::WriteBackendMethods>::autodiff ()
from /home/jed/src/rust-enzyme/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc_driver-65cc4792955af6d5.so
#7 0x00007ffff42e6c1d in <rustc_codegen_ssa::back::lto::LtoModuleCodegen<rustc_codegen_llvm::LlvmCodegenBackend>>::autodiff ()
from /home/jed/src/rust-enzyme/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc_driver-65cc4792955af6d5.so
#8 0x00007ffff439a920 in rustc_codegen_ssa::back::write::generate_lto_work::<rustc_codegen_llvm::LlvmCodegenBackend> ()
from /home/jed/src/rust-enzyme/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc_driver-65cc4792955af6d5.so
#9 0x00007ffff42b4641 in std::sys_common::backtrace::__rust_begin_short_backtrace::<<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa::back::write::start_executing_work<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#5}, core::result::Result<rustc_codegen_ssa::back::write::CompiledModules, ()>>::{closure#0}, core::result::Result<rustc_codegen_ssa::back::write::CompiledModules, ()>> () from /home/jed/src/rust-enzyme/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc_driver-65cc4792955af6d5.so
#10 0x00007ffff43a58a4 in <<std::thread::Builder>::spawn_unchecked_<<rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::spawn_named_thread<rustc_codegen_ssa::back::write::start_executing_work<rustc_codegen_llvm::LlvmCodegenBackend>::{closure#5}, core::result::Result<rustc_codegen_ssa::back::write::CompiledModules, ()>>::{closure#0}, core::result::Result<rustc_codegen_ssa::back::write::CompiledModules, ()>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} ()
from /home/jed/src/rust-enzyme/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/librustc_driver-65cc4792955af6d5.so
#11 0x00007ffff7ecb575 in std::sys::unix::thread::Thread::new::thread_start () from /home/jed/src/rust-enzyme/build/x86_64-unknown-linux-gnu/stage1/bin/../lib/libstd-986b42e05a394a44.so
#12 0x00007ffff36a955a in ?? () from /usr/lib/libc.so.6
#13 0x00007ffff3726a3c in ?? () from /usr/lib/libc.so.6
That looks like the LLVMGetElementType
is being called from within the rust autodiff code, and specifically it's trying to get the element type of something which is not a vector/array (That method only works on vectors and arrays, not pointers, structs, etc).
A debug build may make that easier to find, but @ZuseZ4 does that provide sufficient of a clue for you to look for what's going wrong?
This perhaps is related to opaque pointers (aka now pointers don't have element types), so perhaps that's what's going awry?
Yes, that's just what I was looking for, thanks a lot. Completely missed that I might also need to remove those from the Rust side.
Fixed opaque ptr handling, examples now run and produce correct results in debug mode. However under release mode it segfaults (illegal hw instruction), going to create a new issue. @jedbrown, that should at least allow you to get started. Fixed by #a74948f