[LLVMbugs] [Bug 20353] New: Clang crashes when running user defined LLVM pass with -xclang flag

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 17 19:10:15 PDT 2014


            Bug ID: 20353
           Summary: Clang crashes when running user defined LLVM pass with
                    -xclang flag
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: windxing2007 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This bug appears when using clang to compile a hello world program as below.
#include <stdio.h>
void main()
printf("hello world\n");

The pass loaded to clang is a simple pass which have the following two lines of
  1----Type * ShortTy = IntegerType::get(M.getContext(), 16);
  2----PointerType * Ptr16Ty = PointerType::getUnqual(ShortTy);
If line 2 is removed, then clang won't crash. I'm not sure whether it crashes
because line 2 has error. If it is an error of line 2, please let me know.

The pass is loaded using the command as  below:
clang -Xclang -load -Xclang
/home/jun/llvm-3.x/build/Debug+Asserts/lib/LLVMInst.so  test.c -o test

The backtrace is as below:
0  clang           0x0000000002e19847 llvm::sys::PrintStackTrace(_IO_FILE*) +
1  clang           0x0000000002e19ace
2  clang           0x0000000002e19512
3  libpthread.so.0 0x00007ff04cc13cb0
4  clang           0x0000000002dae406 llvm::PointerType::get(llvm::Type*,
unsigned int) + 118
5  LLVMInst.so     0x00007ff04d03a6c2
6  LLVMInst.so     0x00007ff04d038dca
7  clang           0x0000000002d908c4
llvm::FPPassManager::runOnFunction(llvm::Function&) + 390
8  clang           0x0000000002d90605
llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 89
9  clang           0x0000000002d901cc
llvm::legacy::FunctionPassManager::run(llvm::Function&) + 180
10 clang           0x0000000000f1875b
11 clang           0x0000000000f18917
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*,
clang::BackendAction, llvm::raw_ostream*) + 136
12 clang           0x0000000000f1428e
13 clang           0x00000000011240d8 clang::ParseAST(clang::Sema&, bool, bool)
+ 776
14 clang           0x0000000000cbe96f clang::ASTFrontendAction::ExecuteAction()
+ 321
15 clang           0x0000000000f13724 clang::CodeGenAction::ExecuteAction() +
16 clang           0x0000000000cbe4ae clang::FrontendAction::Execute() + 200
17 clang           0x0000000000c8fd44
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 720
18 clang           0x0000000000c5e63a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1018
19 clang           0x0000000000c4f572 cc1_main(char const**, char const**, char
const*, void*) + 717
20 clang           0x0000000000c59d0a main + 786
21 libc.so.6       0x00007ff04be4f76d __libc_start_main + 237
22 clang           0x0000000000c4ec69
Stack dump:
0.    Program arguments: /usr/local/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
test.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.22 -resource-dir /usr/local/bin/../lib/clang/3.5 -internal-isystem
/usr/local/include -internal-isystem /usr/local/bin/../lib/clang/3.5/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /home/jun/straight-DTA/test -ferror-limit 19
-fmessage-length 171 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -vectorize-slp -load
/home/jun/llvm-3.x/build/Debug+Asserts/lib/LLVMInst.so -o /tmp/test-f83ffb.o -x
c test.c 
1.    <eof> parser at end of file
2.    Per-function optimization
3.    Running pass 'instrument every basic block' on function '@main'
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
clang version 3.5 (trunk 196464) (llvm/trunk 196460)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg:

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140718/d80226f5/attachment.html>

More information about the llvm-bugs mailing list