llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.03k stars 11.96k forks source link

clang crashes when compiling floating point multiplication code with a clang plugin loaded #33986

Open llvmbot opened 7 years ago

llvmbot commented 7 years ago
Bugzilla Link 34638
Version 5.0
OS MacOS X
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@hfinkel

Extended Description

When I try to run my clang plugin on my real codebase, it crashes. I can compile the code without the plugin and I can run the plugin on some (much) simpler code.

Zacs-MacBook-Air:js-api xaxxon$ time /Users/xaxxon/Downloads/clang+llvm-5.0.0/bin/clang++  -DV8TOOLKIT_ENABLE_EASTL_SUPPORT -DV8TOOLKIT_WRAPPER_FAST_COMPILE -I/usr/local/include/SDL2 -I/Users/xaxxon/apb/. -I/Users/xaxxon/apb/include -I/usr/local/include -I/Users/xaxxon/apb -I/Users/xaxxon/apb/glm -I/Users/xaxxon/apb/js-api/apb-js-api-template -I/Users/xaxxon/v8/include  -std=gnu++1z -target x86_64-apple-darwin15.6.0 -Wno-aligned-allocation-unavailable -pedantic -Werror=return-type -msse4.1 -stdlib=libc++ -Xclang -load -Xclang /Users/xaxxon/apb/cmake-build-debug/js-api/libclass_parser_plugin.dylib -fsyntax-only -Xclang -plugin -Xclang v8toolkit-generate-bindings  -g   -o CMakeFiles/apb-js-api.dir/cotire/apb-js-api-template_CXX_unity.cxx.o -c /Users/xaxxon/apb/cmake-build-debug/js-api/cotire/apb-js-api-template_CXX_unity.cxx
0  clang-5.0                    0x000000010d54b1f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  clang-5.0                    0x000000010d54b7a6 SignalHandler(int) + 342
2  libsystem_platform.dylib     0x00007fff9917152a _sigtramp + 26
3  libsystem_platform.dylib     0x81a0796d81a0796d _sigtramp + 3901318237
4  libclass_parser_plugin.dylib 0x0000000111b78f18 handleFloatFloatBinOp((anonymous namespace)::EvalInfo&, clang::Expr const*, llvm::APFloat&, clang::BinaryOperatorKind, llvm::APFloat const&) + 280
5  libclass_parser_plugin.dylib 0x0000000111b77e6f (anonymous namespace)::FloatExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*) + 703
6  libclass_parser_plugin.dylib 0x0000000111b79d93 (anonymous namespace)::FloatExprEvaluator::VisitCastExpr(clang::CastExpr const*) + 195
7  libclass_parser_plugin.dylib 0x0000000111b77c4f (anonymous namespace)::FloatExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*) + 159
8  libclass_parser_plugin.dylib 0x0000000111b79d93 (anonymous namespace)::FloatExprEvaluator::VisitCastExpr(clang::CastExpr const*) + 195
9  libclass_parser_plugin.dylib 0x0000000111b77c4f (anonymous namespace)::FloatExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*) + 159
10 libclass_parser_plugin.dylib 0x0000000111b4ee4c Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) + 796
11 libclass_parser_plugin.dylib 0x0000000111b58aa5 (anonymous namespace)::LValueExprEvaluator::VisitCompoundAssignOperator(clang::CompoundAssignOperator const*) + 389
12 libclass_parser_plugin.dylib 0x0000000111b4ebe1 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) + 177
13 libclass_parser_plugin.dylib 0x0000000111b4aefc EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) + 92
14 libclass_parser_plugin.dylib 0x0000000111b4ccaf clang::Expr::EvaluateForOverflow(clang::ASTContext const&) const + 415
15 libclass_parser_plugin.dylib 0x00000001112c53f4 clang::Sema::CheckForIntOverflow(clang::Expr*) + 260
16 libclass_parser_plugin.dylib 0x00000001112c5699 clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) + 89
17 libclass_parser_plugin.dylib 0x000000011153b1c1 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) + 289
18 libclass_parser_plugin.dylib 0x000000011168fa26 clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>) + 54
19 libclass_parser_plugin.dylib 0x0000000111a0d84d clang::Parser::ParseExprStatement() + 573
20 libclass_parser_plugin.dylib 0x0000000111a0c1e5 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) + 869
21 libclass_parser_plugin.dylib 0x0000000111a0bd64 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) + 180
22 libclass_parser_plugin.dylib 0x0000000111a12b59 clang::Parser::ParseCompoundStatementBody(bool) + 1561
23 libclass_parser_plugin.dylib 0x00000001119db805 clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) + 2581
24 libclass_parser_plugin.dylib 0x00000001119da259 clang::Parser::ParseLambdaExpression() + 377
25 libclass_parser_plugin.dylib 0x00000001119caace clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState, bool) + 5582
26 libclass_parser_plugin.dylib 0x00000001119c6614 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 164
27 libclass_parser_plugin.dylib 0x00000001119cfcd1 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) + 3105
28 libclass_parser_plugin.dylib 0x00000001119c9df0 clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState, bool) + 2288
29 libclass_parser_plugin.dylib 0x00000001119c6614 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 164
30 libclass_parser_plugin.dylib 0x00000001119d36ba clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::SmallVectorImpl<clang::SourceLocation>&, std::__1::function<void ()>) + 186
31 libclass_parser_plugin.dylib 0x00000001119c8d0d clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) + 4621
32 libclass_parser_plugin.dylib 0x00000001119ca71a clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState, bool) + 4634
33 libclass_parser_plugin.dylib 0x00000001119cdc14 clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState, bool) + 18196
34 libclass_parser_plugin.dylib 0x00000001119c6614 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 164
35 libclass_parser_plugin.dylib 0x00000001119d36ba clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::SmallVectorImpl<clang::SourceLocation>&, std::__1::function<void ()>) + 186
36 libclass_parser_plugin.dylib 0x00000001119c8d0d clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) + 4621
37 libclass_parser_plugin.dylib 0x00000001119ca71a clang::Parser::ParseCastExpression(bool, bool, bool&, clang::Parser::TypeCastState, bool) + 4634
38 libclass_parser_plugin.dylib 0x00000001119c6614 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 164
39 libclass_parser_plugin.dylib 0x00000001119c654e clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 14
40 libclass_parser_plugin.dylib 0x0000000111a0d64f clang::Parser::ParseExprStatement() + 63
41 libclass_parser_plugin.dylib 0x0000000111a0c1e5 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) + 869
42 libclass_parser_plugin.dylib 0x0000000111a0bd64 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) + 180
43 libclass_parser_plugin.dylib 0x0000000111a12b59 clang::Parser::ParseCompoundStatementBody(bool) + 1561
44 libclass_parser_plugin.dylib 0x0000000111a13442 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 162
45 libclass_parser_plugin.dylib 0x0000000111a28bf8 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 2616
46 libclass_parser_plugin.dylib 0x00000001119a2104 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 2484
47 libclass_parser_plugin.dylib 0x0000000111a27fc3 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 835
48 libclass_parser_plugin.dylib 0x0000000111a27a43 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 563
49 libclass_parser_plugin.dylib 0x0000000111a26717 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 2519
50 libclass_parser_plugin.dylib 0x0000000111a255d9 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 633
51 libclass_parser_plugin.dylib 0x0000000111990345 clang::ParseAST(clang::Sema&, bool, bool) + 405
52 clang-5.0                    0x000000010dace813 clang::FrontendAction::Execute() + 67
53 clang-5.0                    0x000000010da734b8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1208
54 clang-5.0                    0x000000010db12205 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 4597
55 clang-5.0                    0x000000010c0f7929 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1401
56 clang-5.0                    0x000000010c0f5ab2 main + 11282
57 libdyld.dylib                0x00007fff8f0ae5ad start + 1
Stack dump:
0.  Program arguments: /Users/xaxxon/Downloads/clang+llvm-5.0.0/bin/clang-5.0 -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -fsyntax-only -disable-free -disable-llvm-verifier -discard-value-names -main-file-name apb-js-api-template_CXX_unity.cxx -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -faligned-alloc-unavailable -target-cpu core2 -target-feature +sse4.1 -target-linker-version 264.3.101 -dwarf-column-info -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -resource-dir /Users/xaxxon/Downloads/clang+llvm-5.0.0/lib/clang/5.0.0 -D V8TOOLKIT_ENABLE_EASTL_SUPPORT -D V8TOOLKIT_WRAPPER_FAST_COMPILE -I /usr/local/include/SDL2 -I /Users/xaxxon/apb/. -I /Users/xaxxon/apb/include -I /usr/local/include -I /Users/xaxxon/apb -I /Users/xaxxon/apb/glm -I /Users/xaxxon/apb/js-api/apb-js-api-template -I /Users/xaxxon/v8/include -stdlib=libc++ -Wno-aligned-allocation-unavailable -Werror=return-type -pedantic -std=gnu++1z -fdeprecated-macro -fdebug-compilation-dir /Users/xaxxon/apb/cmake-build-debug/js-api -ferror-limit 19 -fmessage-length 168 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -load /Users/xaxxon/apb/cmake-build-debug/js-api/libclass_parser_plugin.dylib -plugin v8toolkit-generate-bindings -x c++ /Users/xaxxon/apb/cmake-build-debug/js-api/cotire/apb-js-api-template_CXX_unity.cxx 
clang-5.0: error: unable to execute command: Segmentation fault: 11
clang-5.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Users/xaxxon/Downloads/clang+llvm-5.0.0/bin
clang-5.0: 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-5.0: error: unable to execute command: Segmentation fault: 11
clang-5.0: note: diagnostic msg: Error generating preprocessed source(s).

I started trimming my "real" code back to try to find the problem and eventually got found a line that when present crashed the program, but when changed, did not (code slightly simplified from original):

    float result = 3.1415926535f * 1;

If you remove the "* 1" the code compiles and my plugin works fine.

llvmbot commented 7 years ago

linking with -undefined dynamic_lookup fixes the problem, but I don't understand why.

llvmbot commented 7 years ago

A quick-and-easy repro kit is available here:

https://www.dropbox.com/s/3yi1a42otk0tl0w/deleteme.tar.gz?dl=0

llvmbot commented 7 years ago

This has also been reproduced by someone else on 10.12.6 using the clang 5 package downloaded from the llvm download page

llvmbot commented 7 years ago

I grabbed the official 5.0 binary build for mac from the llvm website to try it.

After adding a dummy no-op implementation of

extern "C"                                                                                                                                                              
int futimens(int fd, const struct timespec times[2]) {                                                                                                                  
    return 0;                                                                                                                                                           
}                                                                                                                                                                       

to my plugin (because the clang 5 binary for mac is for 10.12 - I'm on 10.11 and 10.11 doesn't have that available in the OS), I got the same crash.

llvmbot commented 7 years ago

The same code with the llvm download page's binary build for mac for clang 4.0 - the above steps work fine.

llvmbot commented 7 years ago

I've written what I believe to be the simplest no-op plugin:

#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/AST/Comment.h"
#include "llvm/Support/raw_ostream.h"

using namespace clang;
using namespace clang::driver;
using namespace clang::tooling;
using namespace clang::comments;

    /**
     * Defines what will be matched and sent to
     */
    class MyASTConsumer : public clang::ASTConsumer {
    private:

    public:
    MyASTConsumer(CompilerInstance & CI){}

    void HandleTranslationUnit(ASTContext & Context) override {
    }

    };

// This is the class that is registered with LLVM.  PluginASTAction is-a ASTFrontEndAction
class PrintFunctionNamesAction : public clang::PluginASTAction {
public:

    // open up output files
    PrintFunctionNamesAction() {

    }

    // This is called when all parsing is done
    void EndSourceFileAction(){}

protected:
    // The value returned here is used internally to run checks against
    std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance & CI,
                           llvm::StringRef) {
    return llvm::make_unique<MyASTConsumer>(CI);
    }

public:
    ~PrintFunctionNamesAction()=default;
    bool ParseArgs(const CompilerInstance & CI,
           const std::vector<std::string> & args) {
    return true;
    }

    void PrintHelp(llvm::raw_ostream & ros) {
    }

};

static FrontendPluginRegistry::Add <PrintFunctionNamesAction>
X("noop_plugin", "noop plugin");

which I compile with:

$ CLANG_HOME/bin/clang++ \
    -fno-rtti -O0 -g \
    -I/usr/local/include \
        -I$CLANG_HOME/include \
    -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual \
    -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor \
    -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -O3 -DNDEBUG  -fno-rtti \
    -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
        noop_plugin.cpp \
    `$CLANG_HOME/bin/llvm-config --ldflags --libs --system-libs` \
        -dynamiclib -shared -o class_parser.dylib\
        -std=c++14 \
        \
        \
        -l LLVMAArch64AsmParser \
        -l clangFrontend \
        -L$CLANG_HOME/lib -Wl,-headerpad_max_install_names \
        -lclangFrontend \
        -lLLVMLTO -lclangSerialization -lclangASTMatchers -lclangSema -lclangAnalysis -lclangRewriteFrontend -lclangEdit \
        -lclangParse -lclangFrontend -lclangBasic -lclangDriver -lclangAST -lclangLex -lLLVMObjCARCOpts -lLLVMSymbolize \
        -lLLVMDebugInfoPDB -lLLVMDebugInfoDWARF -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo \
        -lLLVMXCoreAsmPrinter -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc \
        -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser \
        -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMSparcAsmPrinter -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen \
        -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMNVPTXCodeGen \
        -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info \
        -lLLVMMSP430AsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo \
        -lLLVMMipsAsmPrinter -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc \
        -lLLVMHexagonInfo -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMBPFAsmPrinter -lLLVMARMDisassembler \
        -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAMDGPUCodeGen \
        -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMAMDGPUAsmPrinter \
        -lLLVMAArch64Disassembler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info \
        -lLLVMAArch64AsmPrinter -lLLVMAArch64Utils -lLLVMMIRParser -lLLVMLibDriver -lLLVMOption -lLLVMTableGen \
        -lLLVMLineEditor -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter \
        -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMPasses \
        -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMDebugInfoCodeView -lLLVMInterpreter \
        -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMInstrumentation -lLLVMProfileData -lLLVMBitWriter \
        -lLLVMOrcJIT -lLLVMTransformUtils -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMRuntimeDyld \
        -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lclangParse -lclangAST -lclangBasic -lclangParse\
    -lclangParse \
        -L/usr/local/lib \
        -lcurses -lpthread  -lm -lfmt 

and then the program:

int main() {
    float result = 1.0 * 1;
}

which I then run the plugin on as such:

clang++ source.cpp  -std=c++17 -Xclang -load -Xclang ./class_parser.dylib  -Xclang -plugin -Xclang noop_plugin

0  clang-5.0                0x0000000109d5a1f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  clang-5.0                0x0000000109d5a7a6 SignalHandler(int) + 342
2  libsystem_platform.dylib 0x00007fff9917152a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 1726540528
4  class_parser.dylib       0x000000010e1752f8 handleFloatFloatBinOp((anonymous namespace)::EvalInfo&, clang::Expr const*, llvm::APFloat&, clang::BinaryOperatorKind, llvm::APFloat const&) + 280
5  class_parser.dylib       0x000000010e17424f (anonymous namespace)::FloatExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*) + 703
6  class_parser.dylib       0x000000010e14b65c Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) + 796
7  class_parser.dylib       0x000000010e14770c EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) + 92
8  class_parser.dylib       0x000000010e1474d8 clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&) const + 376
9  class_parser.dylib       0x000000010d8cb8df (anonymous namespace)::CheckImplicitConversion(clang::Sema&, clang::Expr*, clang::QualType, clang::SourceLocation, bool*) + 927
10 class_parser.dylib       0x000000010d8c3af6 (anonymous namespace)::AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation) + 998
11 class_parser.dylib       0x000000010d8c48cb clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) + 139
12 class_parser.dylib       0x000000010db3a3c1 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) + 289
13 class_parser.dylib       0x000000010d9732f1 clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) + 3937
14 class_parser.dylib       0x000000010de32a11 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) + 3713
15 class_parser.dylib       0x000000010de30087 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 2743
16 class_parser.dylib       0x000000010de2be33 clang::Parser::ParseSimpleDeclaration(unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*) + 723
17 class_parser.dylib       0x000000010de2b8e8 clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 504
18 class_parser.dylib       0x000000010de9a03c clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) + 828
19 class_parser.dylib       0x000000010de99be4 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) + 180
20 class_parser.dylib       0x000000010dea09d9 clang::Parser::ParseCompoundStatementBody(bool) + 1561
21 class_parser.dylib       0x000000010dea12c2 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 162
22 class_parser.dylib       0x000000010deb6a78 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 2616
23 class_parser.dylib       0x000000010de2ff84 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 2484
24 class_parser.dylib       0x000000010deb5e43 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 835
25 class_parser.dylib       0x000000010deb58c3 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 563
26 class_parser.dylib       0x000000010deb4597 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 2519
27 class_parser.dylib       0x000000010deb3459 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 633
28 class_parser.dylib       0x000000010deb30f5 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 37
29 class_parser.dylib       0x000000010de1e18f clang::ParseAST(clang::Sema&, bool, bool) + 351
30 clang-5.0                0x000000010a2dd813 clang::FrontendAction::Execute() + 67
31 clang-5.0                0x000000010a2824b8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1208
32 clang-5.0                0x000000010a321205 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 4597
33 clang-5.0                0x0000000108906929 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1401
34 clang-5.0                0x0000000108904ab2 main + 11282
35 libdyld.dylib            0x00007fff8f0ae5ad start + 1
36 libdyld.dylib            0x000000000000003b start + 1895111311
Stack dump:
0.  Program arguments: /Users/xaxxon/Downloads/clang+llvm-5.0.0/bin/clang-5.0 -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name source.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -faligned-alloc-unavailable -target-cpu core2 -target-linker-version 264.3.101 -dwarf-column-info -debugger-tuning=lldb -resource-dir /Users/xaxxon/Downloads/clang+llvm-5.0.0/lib/clang/5.0.0 -stdlib=libc++ -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /Users/xaxxon/deleteme -ferror-limit 19 -fmessage-length 168 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -load ./class_parser.dylib -plugin noop_plugin -o /var/folders/94/z1tx2t2n0dg2bx5lb315pwl80000gn/T/source-cba5bb.o -x c++ source.cpp 
clang-5.0: error: unable to execute command: Segmentation fault: 11
clang-5.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Users/xaxxon/Downloads/clang+llvm-5.0.0/bin
clang-5.0: 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-5.0: error: unable to execute command: Segmentation fault: 11
clang-5.0: note: diagnostic msg: Error generating preprocessed source(s).

I have no DYLD_LIBRARY_PATH set:

Zacs-MacBook-Air:deleteme xaxxon$ echo DYLD_LIBRARY_PATH
DYLD_LIBRARY_PATH

Zacs-MacBook-Air:deleteme xaxxon$ echo $DYLD_LIBRARY_PATH

Zacs-MacBook-Air:deleteme xaxxon$ 

and my clang is coming from my custom built clang, as described above. (yes I put it in a dir called Downloads even though I didn't download it)

Zacs-MacBook-Air:deleteme xaxxon$ which clang++
/Users/xaxxon/Downloads/clang+llvm-5.0.0/bin/clang++
llvmbot commented 7 years ago

it takes me 6 hours to compile clang, so building bleeding edge is quite painful for me, so I haven't tried to see if it's fixed past the final version of 5.0.0

llvmbot commented 7 years ago

This is on a 2011 macbook air running OS X 10.11.6 and a version of clang 5 I compiled from

./utils/release/test-release.sh -release 5.0.0 -final -triple x86_64-apple-darwin15.6.0