[llvm-bugs] [Bug 27084] New: Segfault in clang::Sema::DeduceFunctionTypeFromReturnExpr

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 26 04:40:16 PDT 2016


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

            Bug ID: 27084
           Summary: Segfault in
                    clang::Sema::DeduceFunctionTypeFromReturnExpr
           Product: clang
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: patek.mail at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

When compiling a C++ source, clang crashed with the following message. Note
that `unknown_id` is really undefined, so the error is correct. When I fix that
error, the source compiles fine (replace `unknown_id` with `Vec2(0.f, 0.f)` to
receive the correct version).

I attach the source and the build script indicated in the crash report. The
whole sources, if necessary, can be found in a branch `clang_bug_in_texture` on
`github.com/honzasp/dort` (the link to the file is
https://github.com/honzasp/dort/blob/clang_bug_in_texture/src/dort/texture_maps.cpp).
The project uses tup as the build system.

src/dort/texture_maps.cpp:36:16: error: use of undeclared identifier
'unknown_id'
        return unknown_id;
               ^
0  libLLVM-3.6.so.1 0x00007f61aec96912 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  libLLVM-3.6.so.1 0x00007f61aec94eb1
2  libpthread.so.0  0x00007f61ad87e340
3  clang            0x0000000000d13252
clang::Sema::DeduceFunctionTypeFromReturnExpr(clang::FunctionDecl*,
clang::SourceLocation, clang::Expr*&, clang::AutoType*) + 274
4  clang            0x0000000000d13836
clang::Sema::ActOnCapScopeReturnStmt(clang::SourceLocation, clang::Expr*) + 278
5  clang            0x0000000000d141f7
clang::Sema::BuildReturnStmt(clang::SourceLocation, clang::Expr*) + 759
6  clang            0x0000000000d149f9
clang::Sema::ActOnReturnStmt(clang::SourceLocation, clang::Expr*,
clang::Scope*) + 9
7  clang            0x0000000000a616c7 clang::Parser::ParseReturnStatement() +
119
8  clang            0x0000000000a6380f
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
+ 2063
9  clang            0x0000000000a63d94
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) + 116
10 clang            0x0000000000a66649
clang::Parser::ParseCompoundStatementBody(bool) + 1673
11 clang            0x0000000000a43e7a
clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) +
874
12 clang            0x0000000000a4580b clang::Parser::ParseLambdaExpression() +
347
13 clang            0x0000000000a37df4 clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::Parser::TypeCastState) + 3860
14 clang            0x0000000000a38fad clang::Parser::ParseCastExpression(bool,
bool, clang::Parser::TypeCastState) + 29
15 clang            0x0000000000a3902f
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 31
16 clang            0x0000000000a3a7b1
clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&,
llvm::SmallVectorImpl<clang::SourceLocation>&, void
(clang::Sema::*)(clang::Scope*, clang::Expr*, llvm::ArrayRef<clang::Expr*>),
clang::Expr*) + 241
17 clang            0x0000000000a3ae20
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) + 848
18 clang            0x0000000000a36f5b clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::Parser::TypeCastState) + 123
19 clang            0x0000000000a38fad clang::Parser::ParseCastExpression(bool,
bool, clang::Parser::TypeCastState) + 29
20 clang            0x0000000000a3756e clang::Parser::ParseCastExpression(bool,
bool, bool&, clang::Parser::TypeCastState) + 1678
21 clang            0x0000000000a38fad clang::Parser::ParseCastExpression(bool,
bool, clang::Parser::TypeCastState) + 29
22 clang            0x0000000000a3902f
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 31
23 clang            0x0000000000a390a9
clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 9
24 clang            0x0000000000a616a0 clang::Parser::ParseReturnStatement() +
80
25 clang            0x0000000000a6380f
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&)
+ 2063
26 clang            0x0000000000a63d94
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, bool, clang::SourceLocation*) + 116
27 clang            0x0000000000a66649
clang::Parser::ParseCompoundStatementBody(bool) + 1673
28 clang            0x0000000000a684fe
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 190
29 clang            0x0000000000a0ee67
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
1015
30 clang            0x0000000000a21832
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1346
31 clang            0x0000000000a0a552
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 274
32 clang            0x0000000000a0ac26
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 1014
33 clang            0x0000000000a0df03
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 259
34 clang            0x0000000000a2d914
clang::Parser::ParseInnerNamespace(std::vector<clang::SourceLocation,
std::allocator<clang::SourceLocation> >&, std::vector<clang::IdentifierInfo*,
std::allocator<clang::IdentifierInfo*> >&, std::vector<clang::SourceLocation,
std::allocator<clang::SourceLocation> >&, unsigned int, clang::SourceLocation&,
clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) + 404
35 clang            0x0000000000a2df5e clang::Parser::ParseNamespace(unsigned
int, clang::SourceLocation&, clang::SourceLocation) + 1454
36 clang            0x0000000000a22974 clang::Parser::ParseDeclaration(unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 660
37 clang            0x0000000000a0df25
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 293
38 clang            0x0000000000a0e64c
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 460
39 clang            0x0000000000a0839b clang::ParseAST(clang::Sema&, bool,
bool) + 283
40 clang            0x00000000006e81d6 clang::FrontendAction::Execute() + 118
41 clang            0x00000000006c7078
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 280
42 clang            0x00000000006b18c4
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1892
43 clang            0x00000000006ac6f8 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 1304
44 clang            0x00000000006aab56 main + 8246
45 libc.so.6        0x00007f61acfa6ec5 __libc_start_main + 245
46 clang            0x00000000006ab74c
Stack dump:
0.    Program arguments: /usr/lib/llvm-3.6/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -disable-free -disable-llvm-verifier
-main-file-name texture_maps.cpp -mrelocation-model static -mthread-model posix
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -target-linker-version 2.24
-momit-leaf-frame-pointer -g -dwarf-column-info -coverage-file
/home/patek/prog/dort/.tup/mnt/@tupjob-2980/home/patek/prog/dort/build/d/texture_maps.o
-resource-dir /usr/lib/llvm-3.6/bin/../lib/clang/3.6.0 -D LUA_USE_APICHECK -I
include -I extern/rply -I extern/stb -I extern/lua -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.3.0/../../../../include/c++/5.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.3.0/../../../../include/x86_64-linux-gnu/c++/5.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.3.0/../../../../include/x86_64-linux-gnu/c++/5.3.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.3.0/../../../../include/c++/5.3.0/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/llvm-3.6/bin/../lib/clang/3.6.0/include -internal-externc-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.3.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -O2 -Wall -Wextra -Wstrict-aliasing
-std=c++1y -fdeprecated-macro -fdebug-compilation-dir
/home/patek/prog/dort/.tup/mnt/@tupjob-2980/home/patek/prog/dort -ferror-limit
19 -fmessage-length 0 -pthread -mstackrealign -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops
-vectorize-slp -o build/d/texture_maps.o -x c++ src/dort/texture_maps.cpp 
1.    src/dort/texture_maps.cpp:41:46: current parser token ';'
2.    src/dort/texture_maps.cpp:3:1: parsing namespace 'dort'
3.    src/dort/texture_maps.cpp:31:93: parsing function body
'cylindrical_texture_map'
4.    src/dort/texture_maps.cpp:31:93: in compound statement ('{}')
5.    src/dort/texture_maps.cpp:32:48: lambda expression parsing
6.    src/dort/texture_maps.cpp:32:74: in compound statement ('{}')
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 3.6.0-2ubuntu1~trusty1 (tags/RELEASE_360/final) (based on
LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://bugs.debian.org/ and include the crash backtrace, preprocessed source,
and associated run script.
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/texture_maps-548610.cpp
clang: note: diagnostic msg: /tmp/texture_maps-548610.sh
clang: note: diagnostic msg: 

The run script (Bugzilla allowed me just one attachment):

"/usr/lib/llvm-3.6/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu"
"-emit-obj" "-disable-free" "-disable-llvm-verifier" "-main-file-name"
"texture_maps.cpp" "-mrelocation-model" "static" "-mthread-model" "posix"
"-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables"
"-fuse-init-array" "-target-cpu" "x86-64" "-target-linker-version" "2.24"
"-momit-leaf-frame-pointer" "-g" "-dwarf-column-info" "-D" "LUA_USE_APICHECK"
"-O2" "-Wall" "-Wextra" "-Wstrict-aliasing" "-std=c++1y" "-fdeprecated-macro"
"-ferror-limit" "19" "-fmessage-length" "0" "-pthread" "-mstackrealign"
"-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-vectorize-loops" "-vectorize-slp" "-x" "c++"
"texture_maps-548610.cpp"

-- 
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/20160326/41b73c46/attachment-0001.html>


More information about the llvm-bugs mailing list