[llvm-bugs] [Bug 34638] New: clang crashes when building "complex" code with a plugin

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 15 18:32:42 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34638

            Bug ID: 34638
           Summary: clang crashes when building "complex" code with a
                    plugin
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: xaxxon at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

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.

-- 
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/20170916/b6f1c5b9/attachment-0001.html>


More information about the llvm-bugs mailing list