Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when explicitly qualifying namespace of concept when using void foo(thing auto) syntax #18

Closed
davidstone opened this issue Sep 8, 2019 · 2 comments

Comments

@davidstone
Copy link

davidstone commented Sep 8, 2019

namespace n {

template<typename T>
concept thing = true;

} // namespace n

void foo(n::thing auto);

https://godbolt.org/z/yQssr1

Stack dump:

  1. Program arguments: /opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -discard-value-names -main-file-name example.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /home/ubuntu/./output.gcno -resource-dir /opt/compiler-explorer/clang-concepts-trunk-20190907/lib/clang/9.0.0 -internal-isystem /opt/compiler-explorer/clang-concepts-trunk-20190907/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/clang-concepts-trunk-20190907/lib/clang/9.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++2a -fdeprecated-macro -fdebug-compilation-dir /home/ubuntu -ferror-limit 19 -fmessage-length 0 -fno-implicit-modules -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -fconcepts-ts -mllvm --x86-asm-syntax=intel -faddrsig -o ./output.s -x c++

  2. :8:13: current parser token 'thing'

#0 0x000056327ee1a60a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x270060a)

#1 0x000056327ee183d4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x26fe3d4)

#2 0x000056327ee18512 SignalHandler(int) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x26fe512)

#3 0x00007f2e59907890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)

#4 0x0000563280e79de7 clang::DeclContext::lookup(clang::DeclarationName) const (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x475fde7)

#5 0x00005632809c47e5 LookupDirect(clang::Sema&, clang::LookupResult&, clang::DeclContext const*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x42aa7e5)

#6 0x00005632809c52b0 clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*, bool) (.part.1134) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x42ab2b0)

#7 0x000056328075e5a1 clang::Sema::getTypeName(clang::IdentifierInfo const&, clang::SourceLocation, clang::Scope*, clang::CXXScopeSpec*, bool, bool, clang::OpaquePtrclang::QualType, bool, bool, bool, clang::IdentifierInfo**) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x40445a1)

#8 0x00005632804e326b clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(clang::CXXScopeSpec&, bool) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3dc926b)

#9 0x00005632804e5e4f clang::Parser::TryAnnotateTypeOrScopeToken() (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3dcbe4f)

#10 0x00005632805926e5 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3e786e5)

#11 0x0000563280592df1 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3e78df1)

#12 0x0000563280592df1 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3e78df1)

#13 0x0000563280592df1 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3e78df1)

#14 0x0000563280592df1 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3e78df1)

<snip...>

llvm#253 0x0000563280592df1 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3e78df1)

llvm#254 0x0000563280592df1 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3e78df1)

llvm#255 0x0000563280592df1 clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*) (/opt/compiler-explorer/clang-concepts-trunk-20190907/bin/clang-9+0x3e78df1)

clang-9: error: unable to execute command: Segmentation fault (core dumped)

clang-9: error: clang frontend command failed due to signal (use -v to see invocation)

Compiler returned: 254

@davidstone
Copy link
Author

It looks like this doesn't always lead to an infinite loop + crash. I've also experienced clang simply saying that it cannot find n::thing with more complicated code.

@davidstone
Copy link
Author

Resolved in latest commit

saarraz pushed a commit that referenced this issue Jan 23, 2020
This reverts commit e57a9ab.

Parser/cxx2a-placeholder-type-constraint.cpp has MSan failures.

Present at 7b81c3f:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/17133/steps/check-clang%20msan/logs/stdio
not present at eaa594f:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/17132/steps/check-clang%20msan/logs/stdio

Stack trace:
```
==57032==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0xccfe016 in clang::AutoTypeLoc::getLocalSourceRange() const /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/include/clang/AST/TypeLoc.h:2036:19
    #1 0xcc56758 in CheckDeducedPlaceholderConstraints(clang::Sema&, clang::AutoType const&, clang::AutoTypeLoc, clang::QualType) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4505:56
    #2 0xcc550ce in clang::Sema::DeduceAutoType(clang::TypeLoc, clang::Expr*&, clang::QualType&, llvm::Optional<unsigned int>, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4707:11
    #3 0xcc52407 in clang::Sema::DeduceAutoType(clang::TypeSourceInfo*, clang::Expr*&, clang::QualType&, llvm::Optional<unsigned int>, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4457:10
    #4 0xba38332 in clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, clang::SourceRange, bool, clang::Expr*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11351:7
    #5 0xba3a8a9 in clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11385:26
    #6 0xba3c520 in clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:11725:9
    #7 0xb39c498 in clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2399:17
    #8 0xb394d80 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2128:21
    #9 0xb383bbf in clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:1848:10
    #10 0xb383129 in clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, clang::SourceLocation*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/PointerUnion.h
    #11 0xb53a388 in clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseStmt.cpp:221:13
    #12 0xb539309 in clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseStmt.cpp:106:20
    #13 0xb55610e in clang::Parser::ParseCompoundStatementBody(bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseStmt.cpp:1079:11
    #14 0xb559529 in clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseStmt.cpp:2204:21
    #15 0xb33c13e in clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1339:10
    #16 0xb394703 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2068:11
    #17 0xb338e52 in clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1099:10
    #18 0xb337674 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:1115:12
    #19 0xb334a96 in clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:935:12
    #20 0xb32f12a in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/Parser.cpp:686:12
    #21 0xb31e193 in clang::ParseAST(clang::Sema&, bool, bool) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseAST.cpp:158:20
    #22 0x80263f0 in clang::FrontendAction::Execute() /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Frontend/FrontendAction.cpp:936:8
    #23 0x7f2a257 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:965:33
    #24 0x8288bef in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:290:25
    #25 0xad44c2 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/cc1_main.cpp:239:15
    #26 0xacd76a in ExecuteCC1Tool(llvm::ArrayRef<char const*>) /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/driver.cpp:325:12
    #27 0xacc9fd in main /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/tools/driver/driver.cpp:398:12
    #28 0x7f7d82cdb2e0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202e0)
    #29 0xa4dde9 in _start (/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-11+0xa4dde9)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant