revng icon indicating copy to clipboard operation
revng copied to clipboard

Failed to translate to simple Linux AArch64 binary

Open yomaytk opened this issue 1 year ago • 2 comments
trafficstars

I checked out the latest commit of revng and I tried translating the simple hello world arm64 binary using revng as follows according to README, but I failed to translate.

$ gcc -static -o hello.gcc.arm hello.c
$ ./bin/revng translate hello.gcc.arm
// hello.c
#include <stdio.h>
int main() {
    printf("Hello, World!\n");
    return 0;
}

The simple arm64 binary I used was generated by clang or gcc. Do you have a plan to deal with these problems? I attached those two simple arm64 binaries compiled by clang and gcc. binaries.zip

ref: https://github.com/revng/revng/issues/317

yomaytk avatar Feb 21 '24 06:02 yomaytk

I failed to translate

Can you report the precise error?

Do you have a plan to deal with these problems?

We plan to handle crashes during translation, but crashes during execution are going to be marked as low-prio.

aleclearmind avatar Mar 04 '24 11:03 aleclearmind

Thank you for reply. When I tried compiling simple hello world program hello.gcc.arm included binaries.zip attached to the first comment, the error following occured. hello.gcc.arm was generated by gcc.

$ file hello.gcc.arm
hello.gcc.arm: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=42486ccd323c8b8847668173a9e275dd3b1a2e52, for GNU/Linux 3.7.0, not stripped
$ ./bin/revng translate hello.gcc.arm
Assertion failed at /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/include/revng/ValueMaterializer/ControlFlowEdgesGraph.h:44

It != NodeMap.end()
PLEASE submit a bug report to https://github.com/revng/revng and include the crash backtrace
Stack dump:
0.	Program arguments: libexec/revng/revng-pipeline -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngRecompile.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngBasicAnalyses.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngABI.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngModel.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngYieldPipes.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngABIAnalyses.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngModelImporterBinary.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngFunctionIsolation.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngModelImporter.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngTypeShrinking.so -load /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/lib/revng/analyses/librevngEarlyFunctionAnalysis.so -P /home/masashiyoshimura/workspace/compiler/orchestra/build/revng/optimized/share/revng/pipelines/revng-pipelines.yml --analyze=initial/import-binary/input/:binary --analyze=initial/add-primitive-types/ --analyze=lift/detect-abi/module.ll/:root --produce=recompile/output/:translated -i hello.gcc.arm:begin/input -o hello.gcc.arm.translated:recompile/output --compile-opt-level=0
1.	Running pass 'Lift Pass' on module 'revng.module'.
 #0 0x00007f3180df768e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Unix/Signals.inc:570:13
 #1 0x00007f3180df59f4 llvm::sys::RunSignalHandlers() /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Signals.cpp:105:18
 #2 0x00007f3180df7bfd SignalHandler(int) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/Support/Unix/Signals.inc:415:1
 #3 0x00007f318471d420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f31808e900b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f31808c8859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f318427c699 /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Support/Assert.cpp:17:3
 #7 0x00007f318427c630 report(char const*, char const*, unsigned int, char const*) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Support/Assert.cpp:21:0
 #8 0x00007f317f30bfca llvm::DenseMapIterator<llvm::BasicBlock*, ForwardNode<ControlFlowEdgesNode, Empty, true, 2ul, std::__1::integral_constant<bool, false>, 16ul, true>*, llvm::DenseMapInfo<llvm::BasicBlock*, void>, llvm::detail::DenseMapPair<llvm::BasicBlock*, ForwardNode<ControlFlowEdgesNode, Empty, true, 2ul, std::__1::integral_constant<bool, false>, 16ul, true>*>, false>::operator->() const /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/ADT/DenseMap.h:1243:5
 #9 0x00007f317f30bfca ControlFlowEdgesGraph::at(llvm::BasicBlock*) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/include/revng/ValueMaterializer/ControlFlowEdgesGraph.h:45:12
#10 0x00007f317f308d34 runAVI(DataFlowGraph const&, llvm::Instruction*, llvm::DominatorTree const&, llvm::LazyValueInfo&, bool) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/ValueMaterializer/AdvancedValueInfo.cpp:248:33
#11 0x00007f317f328109 ValueMaterializer::computeOracleConstraints() /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/ValueMaterializer/ValueMaterializer.cpp:62:14
#12 0x00007f317f327d9f ValueMaterializer::run() /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/ValueMaterializer/ValueMaterializer.cpp:38:3
#13 0x00007f317f464938 std::__1::__optional_storage_base<std::__1::vector<MaterializedValue, std::__1::allocator<MaterializedValue>>, false>::has_value[abi:v160001]() const /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/clang-release/bin/../include/c++/v1/optional:331:22
#14 0x00007f317f464938 std::__1::optional<std::__1::vector<MaterializedValue, std::__1::allocator<MaterializedValue>>>::operator bool[abi:v160001]() const /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/clang-release/bin/../include/c++/v1/optional:985:64
#15 0x00007f317f464938 ValueMaterializerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Lift/ValueMaterializerPass.cpp:117:9
#16 0x00007f317f461662 llvm::detail::PassModel<llvm::Function, ValueMaterializerPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/IR/PassManagerInternal.h:89:5
#17 0x00007f318183157d void llvm::PassInstrumentation::runAfterPass<llvm::Function, llvm::detail::PassConcept<llvm::Function, llvm::AnalysisManager<llvm::Function>>>(llvm::detail::PassConcept<llvm::Function, llvm::AnalysisManager<llvm::Function>> const&, llvm::Function const&, llvm::PreservedAnalyses const&) const /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/IR/PassInstrumentation.h:256:9
#18 0x00007f318183157d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/include/llvm/IR/PassManager.h:535:10
#19 0x00007f317f451511 llvm::SmallPtrSetImplBase::isSmall() const /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/ADT/SmallPtrSet.h:195:33
#20 0x00007f317f451511 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/ADT/SmallPtrSet.h:83:10
#21 0x00007f317f451511 llvm::PreservedAnalyses::~PreservedAnalyses() /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/IR/PassManager.h:158:7
#22 0x00007f317f451511 RootAnalyzer::optimize(llvm::Function*, MetaAddress::Features const&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Lift/RootAnalyzer.cpp:657:5
#23 0x00007f317f453ba2 RootAnalyzer::cloneOptimizeAndHarvest(llvm::Function*) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Lift/RootAnalyzer.cpp:856:3
#24 0x00007f317f43d7c3 JumpTargetManager::harvest() /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Lift/JumpTargetManager.cpp:1249:5
#25 0x00007f317f43ce08 std::__1::vector<std::__1::pair<MetaAddress, llvm::BasicBlock*>, std::__1::allocator<std::__1::pair<MetaAddress, llvm::BasicBlock*>>>::empty[abi:v160001]() const /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/clang-release/bin/../include/c++/v1/vector:552:23
#26 0x00007f317f43ce08 JumpTargetManager::peek() /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Lift/JumpTargetManager.cpp:789:23
#27 0x00007f317f3c201e std::__1::tuple<MetaAddress&, llvm::BasicBlock*&>& std::__1::tuple<MetaAddress&, llvm::BasicBlock*&>::operator=[abi:v160001]<MetaAddress, llvm::BasicBlock*, 0>(std::__1::pair<MetaAddress, llvm::BasicBlock*>&&) /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/clang-release/bin/../include/c++/v1/tuple:1256:30
#28 0x00007f317f3c201e CodeGenerator::translate(std::__1::optional<unsigned long>) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Lift/CodeGenerator.cpp:1096:37
#29 0x00007f317f42207d LiftPass::runOnModule(llvm::Module&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Lift/Lift.cpp:146:1
#30 0x00007f31817f3632 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:0:27
#31 0x00007f31817f3632 llvm::legacy::PassManagerImpl::run(llvm::Module&) /builds/gitlab/revng/orchestra/orchestra/sources/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:543:44
#32 0x00007f317f422e9b revng::pipes::Lift::run(pipeline::ExecutionContext&, revng::pipes::FileContainer<&revng::kinds::Binary, &revng::pipes::BinaryFileName.<char const at offset 0>, &revng::pipes::BinaryFileMIMEType.<char const at offset 0>, &revng::pipes::BinaryFileSuffix.<char const at offset 0>> const&, pipeline::LLVMContainer&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Lift/LiftPipe.cpp:48:7
#33 0x00007f317f43405a llvm::Error::setChecked(bool) /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/Support/Error.h:300:13
#34 0x00007f317f43405a llvm::Error::operator=(llvm::Error&&) /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/Support/Error.h:215:5
#35 0x00007f317f43405a llvm::Error::Error(llvm::Error&&) /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/Support/Error.h:192:11
#36 0x00007f317f43405a pipeline::InvokableWrapperImpl<revng::pipes::Lift>::run(pipeline::ExecutionContext&, pipeline::ContainerSet&, llvm::StringMap<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, llvm::MallocAllocator> const&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/include/revng/Pipeline/Invokable.h:433:12
#37 0x00007f317f43405a pipeline::detail::PipeWrapperImpl<revng::pipes::Lift>::run(pipeline::ExecutionContext&, pipeline::ContainerSet&, llvm::StringMap<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, llvm::MallocAllocator> const&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/include/revng/Pipeline/Pipe.h:181:22
#38 0x00007f3185239789 llvm::Error::getPtr() const /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/Support/Error.h:272:42
#39 0x00007f3185239789 llvm::Error::operator bool() /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/Support/Error.h:235:16
#40 0x00007f3185239789 llvm::cantFail(llvm::Error, char const*) /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/Support/Error.h:746:7
#41 0x00007f3185239789 pipeline::Step::run(pipeline::ContainerSet&&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Pipeline/Step.cpp:282:5
#42 0x00007f318522d6aa pipeline::Runner::run(llvm::StringRef, pipeline::ContainerToTargetsMap const&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Pipeline/Runner.cpp:381:5
#43 0x00007f318522c529 llvm::Error::getPtr() const /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/Support/Error.h:272:42
#44 0x00007f318522c529 llvm::Error::operator bool() /home/masashiyoshimura/workspace/compiler/orchestra/root/lib64/llvm/llvm/include/llvm/Support/Error.h:235:16
#45 0x00007f318522c529 pipeline::Runner::runAnalysis(llvm::StringRef, llvm::StringRef, pipeline::ContainerToTargetsMap const&, llvm::StringMap<pipeline::ContainerToTargetsMap, llvm::MallocAllocator>&, llvm::StringMap<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, llvm::MallocAllocator> const&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/lib/Pipeline/Runner.cpp:276:19
#46 0x000055662489f715 runAnalysis(pipeline::Runner&, llvm::StringRef) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/tools/pipeline/Main.cpp:138:25
#47 0x000055662489f715 runPipeline(pipeline::Runner&) /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/tools/pipeline/Main.cpp:147:7
#48 0x000055662489f715 main /home/masashiyoshimura/workspace/compiler/orchestra/sources/revng/tools/pipeline/Main.cpp:205:3
#49 0x00007f31808ca083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3
#50 0x000055662489e6d9 _start init.c:0:0

yomaytk avatar Mar 05 '24 02:03 yomaytk