| Issue |
114441
|
| Summary |
error: unable to execute command: Segmentation fault (core dumped)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
maxknows2001
|
```c++
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
using namespace llvm;
namespace {
struct SkeletonPass : public PassInfoMixin<SkeletonPass> {
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM) {
for (auto &F : M) {
errs() << F.getName() << "\n";
if (F.getName() == "main") {
LLVMContext &context = F.getContext();
BasicBlock *ExitBB = BasicBlock::Create(context, "exit", &F);
}
}
return PreservedAnalyses::all();
};
};
}
extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo
llvmGetPassPluginInfo() {
return {
.APIVersion = LLVM_PLUGIN_API_VERSION,
.PluginName = "pass",
.PluginVersion = "v0.1",
.RegisterPassBuilderCallbacks = [](PassBuilder &PB) {
PB.registerPipelineStartEPCallback(
[](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(SkeletonPass());
});
}
};
}
```
I am trying to compile the helloworld program with the pass shown above using the command
```shell
clang++ -fpass-plugin=skeleton/SkeletonPass.so ../../helloWorld.cpp
```
Due to the fact that I added the base block in the pass, I get an error when compiling helloworld:
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation).
Without adding a base block, everything compiles perfectly. I've tried using both clang version 14 and 20. Below is the full output:
```shell
~/llvm-pass-skeleton/build$ clang++ -fpass-plugin=skeleton/SkeletonPass.so ../../helloWorld.cpp
__cxx_global_var_init
_ZNSt8ios_base4InitC1Ev
_ZNSt8ios_base4InitD1Ev
__cxa_atexit
main
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
_GLOBAL__sub_I_helloWorld.cpp
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/lib/llvm-14/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name helloWorld.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/home/max/llvm-pass-skeleton/build -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/home/max/llvm-pass-skeleton/build -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -fpass-plugin=skeleton/SkeletonPass.so -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/helloWorld-dd29e8.o -x c++ ../../helloWorld.cpp
1. <eof> parser at end of file
2. Optimizer
#0 0x00007d51d063fd01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3fd01)
#1 0x00007d51d063da3e llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3da3e)
#2 0x00007d51d0640236 (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe40236)
#3 0x00007d51cf042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007d51d19ac821 llvm::isInlineViable(llvm::Function&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x21ac821)
#5 0x00007d51d15e5736 llvm::AlwaysInlinerPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x1de5736)
#6 0x00007d51d314812d (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0x394812d)
#7 0x00007d51d07ad60e llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xfad60e)
#8 0x00007d51d7a62b9b (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1862b9b)
#9 0x00007d51d7a56a52 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1856a52)
#10 0x00007d51d7d7c855 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b7c855)
#11 0x00007d51d6c04824 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xa04824)
#12 0x00007d51d7d78b71 clang::CodeGenAction::ExecuteAction() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b78b71)
#13 0x00007d51d8714b57 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x2514b57)
#14 0x00007d51d866c3a6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x246c3a6)
#15 0x00007d51d878e45b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x258e45b)
#16 0x000000000041328b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-14/bin/clang+0x41328b)
#17 0x00000000004114bc (/usr/lib/llvm-14/bin/clang+0x4114bc)
#18 0x0000000000411307 main (/usr/lib/llvm-14/bin/clang+0x411307)
#19 0x00007d51cf029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#20 0x00007d51cf029e40 call_init ./csu/../csu/libc-start.c:128:20
#21 0x00007d51cf029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#22 0x000000000040e3b5 _start (/usr/lib/llvm-14/bin/clang+0x40e3b5)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/helloWorld-07da6a.cpp
clang: note: diagnostic msg: /tmp/helloWorld-07da6a.sh
clang: note: diagnostic msg:
********************
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs