Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIRV::SPIRVBinary::validate assertion crashed #61720

Open
thenumbernine opened this issue Mar 27, 2023 · 1 comment
Open

SPIRV::SPIRVBinary::validate assertion crashed #61720

thenumbernine opened this issue Mar 27, 2023 · 1 comment

Comments

@thenumbernine
Copy link

thenumbernine commented Mar 27, 2023

Hello, I crashed LLVM, and it asked me to submit a bug, so here it is:

> llvm-spirv "cache/0c2c3f7472583358/bc/solver.bc" -o "cache/0c2c3f7472583358/spv/solver.spv"
llvm-spirv: ./lib/SPIRV/libSPIRV/SPIRVInstruction.h:636: virtual void SPIRV::SPIRVBinary::validate() const: Assertion `(Op1Ty->isTypeInt() || Op2Ty->isTypeFloat()) && "Invalid type for Binary instruction"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: llvm-spirv cache/0c2c3f7472583358/bc/solver.bc -o cache/0c2c3f7472583358/spv/solver.spv
1.	Running pass 'LLVMToSPIRV' on module 'cache/0c2c3f7472583358/bc/solver.bc'.
 #0 0x00007fd268451a61 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe51a61)
 #1 0x00007fd26844f78e llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe4f78e)
 #2 0x00007fd268451f96 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe51f96)
 #3 0x00007fd266e3bcf0 (/lib/x86_64-linux-gnu/libc.so.6+0x3bcf0)
 #4 0x00007fd266e9226b __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fd266e9226b __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007fd266e9226b pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007fd266e3bc46 raise ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007fd266e227fc abort ./stdlib/abort.c:81:7
 #9 0x00007fd266e2271b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007fd266e33596 (/lib/x86_64-linux-gnu/libc.so.6+0x33596)
#11 0x00007fd26e14fa4f SPIRV::SPIRVBinary::validate() const ./build/lib/SPIRV/./lib/SPIRV/libSPIRV/SPIRVInstruction.h:636:7
#12 0x00007fd26e245054 SPIRV::SPIRVInstTemplateBase::create(spv::Op, SPIRV::SPIRVType*, unsigned int, std::vector<unsigned int, std::allocator<unsigned int>> const&, SPIRV::SPIRVBasicBlock*, SPIRV::SPIRVModule*) ./build/lib/SPIRV/./lib/SPIRV/libSPIRV/SPIRVInstruction.h:207:0
#13 0x00007fd26e2541e3 SPIRV::SPIRVModuleImpl::addBinaryInst(spv::Op, SPIRV::SPIRVType*, SPIRV::SPIRVValue*, SPIRV::SPIRVValue*, SPIRV::SPIRVBasicBlock*) ./build/lib/SPIRV/./lib/SPIRV/libSPIRV/SPIRVModule.cpp:1352:0
#14 0x00007fd26e1b2401 SPIRV::LLVMToSPIRVBase::transBinaryInst(llvm::BinaryOperator*, SPIRV::SPIRVBasicBlock*) ./build/lib/SPIRV/./lib/SPIRV/SPIRVWriter.cpp:1030:22
#15 0x00007fd26e1b6994 SPIRV::LLVMToSPIRVBase::transValueWithoutDecoration(llvm::Value*, SPIRV::SPIRVBasicBlock*, bool, SPIRV::LLVMToSPIRVBase::FuncTransMode) ./build/lib/SPIRV/./lib/SPIRV/SPIRVWriter.cpp:1674:20
#16 0x00007fd26e1af065 SPIRV::LLVMToSPIRVBase::transValue(llvm::Value*, SPIRV::SPIRVBasicBlock*, bool, SPIRV::LLVMToSPIRVBase::FuncTransMode) ./build/lib/SPIRV/./lib/SPIRV/SPIRVWriter.cpp:1011:40
#17 0x00007fd26e1c8ba3 llvm::ilist_node_base<false>::getNext() const /usr/lib/llvm-14/include/llvm/ADT/ilist_node_base.h:29:45
#18 0x00007fd26e1c8ba3 llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>>::getNext() /usr/lib/llvm-14/include/llvm/ADT/ilist_node.h:67:66
#19 0x00007fd26e1c8ba3 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, false>::operator++() /usr/lib/llvm-14/include/llvm/ADT/ilist_iterator.h:157:25
#20 0x00007fd26e1c8ba3 SPIRV::LLVMToSPIRVBase::transFunction(llvm::Function*) ./build/lib/SPIRV/./lib/SPIRV/SPIRVWriter.cpp:3976:21
#21 0x00007fd26e1cb4c8 SPIRV::LLVMToSPIRVBase::translate() ./build/lib/SPIRV/./lib/SPIRV/SPIRVWriter.cpp:4040:17
#22 0x00007fd26e1ae20c SPIRV::LLVMToSPIRVBase::runLLVMToSPIRV(llvm::Module&) ./build/lib/SPIRV/./lib/SPIRV/SPIRVWriter.cpp:170:1
#23 0x00007fd26858d306 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xf8d306)
#24 0x00007fd26e1ce31c llvm::writeSpirv(llvm::Module*, SPIRV::TranslatorOpts const&, std::ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) ./build/lib/SPIRV/./lib/SPIRV/SPIRVWriter.cpp:4895:19
#25 0x000055d9813dfc86 convertLLVMToSPIRV ./build/tools/llvm-spirv/./tools/llvm-spirv/llvm-spirv.cpp:328:3
#26 0x000055d9813dfc86 main ./build/tools/llvm-spirv/./tools/llvm-spirv/llvm-spirv.cpp:730:30
#27 0x00007fd266e23510 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#28 0x00007fd266e235c9 call_init ./csu/../csu/libc-start.c:128:20
#29 0x00007fd266e235c9 __libc_start_main ./csu/../csu/libc-start.c:368:5
#30 0x000055d9813e0605 (/usr/bin/llvm-spirv-14+0x26605)
Aborted (core dumped)

Here's how the bytecode was compiled:

> clang -v -Xclang -finclude-default-header --target=spirv64-unknown-unknown -emit-llvm -c -o "cache/0c2c3f7472583358/bc/solver.bc" "cache/0c2c3f7472583358/src/solver.clcpp"
Ubuntu clang version 15.0.6
Target: spirv64-unknown-unknown
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-15/bin/clang" -cc1 -triple spirv64-unknown-unknown -Wspir-compat -no-opaque-pointers -emit-llvm-bc -emit-llvm-uselists -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name solver.clcpp -mrelocation-model static -mframe-pointer=all -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/chris/Projects/lua/hydro-cl -resource-dir /usr/lib/llvm-15/lib/clang/15.0.6 -fdebug-compilation-dir=/home/chris/Projects/lua/hydro-cl -ferror-limit 19 -finclude-default-header -fdeclare-opencl-builtins -fgnuc-version=4.2.1 -fno-threadsafe-statics -fcolor-diagnostics -finclude-default-header -o cache/0c2c3f7472583358/bc/solver.bc -x clcpp cache/0c2c3f7472583358/src/solver.clcpp
clang -cc1 version 15.0.6 based upon LLVM 15.0.6 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/llvm-15/lib/clang/15.0.6/include
 /usr/include
End of search list.

The code that was being compiled is 12,000 lines long, IDK if you want me to post that as well.

@EugeneZelenko EugeneZelenko added SPIR-V SPIR-V language support backend:SPIR-V and removed new issue SPIR-V SPIR-V language support labels Mar 27, 2023
@jcranmer-intel
Copy link
Contributor

The crash in question is in the LLVM SPIR-V translator tool, located at https://github.com/KhronosGroup/SPIRV-LLVM-Translator, not in llvm itself.

As for tests, it's not really actionable without the original source code. You can run it through creduce to get a much smaller file for reproducing the same failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants