[LLVMbugs] [Bug 16363] New: Segmentation fault when preprocessing in assembler-with-cpp mode

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 18 11:05:15 PDT 2013


            Bug ID: 16363
           Summary: Segmentation fault when preprocessing in
                    assembler-with-cpp mode
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aseipp at pobox.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

While porting the Glasgow Haskell Compiler to use Clang as its preprocessor
(and the compiler for its runtime,) I ran across Clang's strict C99 rules about
the hash operator in macro bodies. We tend to violate these rules egregiously
in GHC. As a result, I switched 'clang -E' to use '-x assembler-with-cpp', but
this caused some segmentation faults in the frontend.

The stack trace is below, along with the Clang and LLVM version. Attached are
two files spit out by the compiler during the segfault; they cleanly reproduce
the bug on our source code if you run the shell script. The original source
file is here:

$ clang -cc1 -version
LLVM (http://llvm.org/):
  LLVM version 3.4svn
  Optimized build.
  Built Jun 17 2013 (07:52:23).
  Default target: x86_64-unknown-linux-gnu
  Host CPU: corei7-avx


0  clang-3.4       0x0000000001433852 llvm::sys::PrintStackTrace(_IO_FILE*) +
1  clang-3.4       0x00000000014334d9
2  libpthread.so.0 0x00007f3b777f0bd0
3  clang-3.4       0x00000000016e4fa0
clang::MacroArgs::getStringifiedArgument(unsigned int, clang::Preprocessor&,
clang::SourceLocation, clang::SourceLocation) + 80
4  clang-3.4       0x00000000016df857
clang::TokenLexer::ExpandFunctionArguments() + 1959
5  clang-3.4       0x00000000016dfd63 clang::TokenLexer::Init(clang::Token&,
clang::SourceLocation, clang::MacroInfo*, clang::MacroArgs*) + 211
6  clang-3.4       0x00000000016c0ae9
clang::Preprocessor::EnterMacro(clang::Token&, clang::SourceLocation,
clang::MacroInfo*, clang::MacroArgs*) + 457
7  clang-3.4       0x00000000016ccd40
clang::MacroDirective*) + 544
8  clang-3.4       0x00000000016daeeb
clang::Preprocessor::HandleIdentifier(clang::Token&) + 827
9  clang-3.4       0x00000000016997a2
clang::Lexer::LexIdentifier(clang::Token&, char const*) + 674
10 clang-3.4       0x000000000169a206
clang::Lexer::LexTokenInternal(clang::Token&) + 1974
11 clang-3.4       0x00000000016527bb
clang::DoPrintPreprocessedInput(clang::Preprocessor&, llvm::raw_ostream*,
clang::PreprocessorOutputOptions const&) + 2395
12 clang-3.4       0x000000000163a26d
clang::PrintPreprocessedAction::ExecuteAction() + 301
13 clang-3.4       0x0000000001636be9 clang::FrontendAction::Execute() + 185
14 clang-3.4       0x00000000016183d5
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 293
15 clang-3.4       0x00000000014362ba
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1546
16 clang-3.4       0x000000000073c648 cc1_main(char const**, char const**, char
const*, void*) + 1160
17 clang-3.4       0x000000000072560c main + 8076
18 libc.so.6       0x00007f3b76c1cea5 __libc_start_main + 245
19 clang-3.4       0x000000000073a235
Stack dump:
0.    Program arguments: /home/a/code/llvm-rel-install/bin/clang-3.4 -cc1
-triple x86_64-unknown-linux-gnu -E -disable-free -disable-llvm-verifier
-main-file-name Types.hs -mrelocation-model static -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -D TABLES_NEXT_TO_CODE -D
__GLASGOW_HASKELL__=707 -D linux_BUILD_OS=1 -D x86_64_BUILD_ARCH=1 -D
linux_HOST_OS=1 -D x86_64_HOST_ARCH=1 -D __SSE__=1 -D __SSE2__=1
-Wno-invalid-pp-token -ferror-limit 19 -fmessage-length 0 -mstackrealign
-fobjc-runtime=gcc -fobjc-default-synthesize-properties
-fdiagnostics-show-option -backend-option -vectorize-loops -traditional-cpp -x
assembler-with-cpp Types-52rkoJ -undef 
Segmentation fault (core dumped)

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/20130618/04d8144f/attachment.html>

More information about the llvm-bugs mailing list