Skip to content

I got a crash when I was compiling a test. Clang12 using c++20 templated lambdas #49063

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

Open
Sebanisu opened this issue Mar 25, 2021 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party

Comments

@Sebanisu
Copy link

Bugzilla Link 49719
Version trunk
OS Linux
Attachments reduced test case
CC @zygoloid

Extended Description

Stack dump:
0. Program arguments: /usr/lib/llvm-12/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name random_test.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -sys-header-deps -D CMAKE_INTDIR="Debug" -Wall -Wextra -Wshadow -Wno-error=shadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Werror -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -faddrsig -x c++ random_test-7f79f0.cpp

  1.  random_test-7f79f0.cpp:2:21: current parser token ')'
    
  2.  random_test-7f79f0.cpp:1:23: instantiating function definition '(anonymous class)::operator()<>'
    

#​0 0x00007f7ffc838ea3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-12.so.1+0xbd8ea3)
#​1 0x00007f7ffc8371c0 llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-12.so.1+0xbd71c0)
#​2 0x00007f7ffc83950f (/lib/x86_64-linux-gnu/libLLVM-12.so.1+0xbd950f)
#​3 0x00007f80040823c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#​4 0x00007f8001e3004e clang::ASTContext::getSubstTemplateTypeParmType(clang::TemplateTypeParmType const*, clang::QualType) const (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0xa1004e)
#​5 0x00007f80028e3028 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x14c3028)
#​6 0x00007f80028df7a2 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x14bf7a2)
#​7 0x00007f80028e4b03 clang::Sema::SubstParmVarDecl(clang::ParmVarDecl*, clang::MultiLevelTemplateArgumentList const&, int, llvm::Optional, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x14c4b03)
#​8 0x00007f8002927474 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1507474)
#​9 0x00007f8002379f3b clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0xf59f3b)
#​10 0x00007f800292056b clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x150056b)
#​11 0x00007f8002912bc8 clang::Sema::FindInstantiatedDecl(clang::SourceLocation, clang::NamedDecl*, clang::MultiLevelTemplateArgumentList const&, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x14f2bc8)
#​12 0x00007f80028fbab4 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x14dbab4)
#​13 0x00007f80028ea282 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x14ca282)
#​14 0x00007f80029003fe (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x14e03fe)
#​15 0x00007f80028ea221 clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x14ca221)
#​16 0x00007f8002922b1e clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1502b1e)
#​17 0x00007f8002379f3b clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0xf59f3b)
#​18 0x00007f800289c6f0 clang::Sema::DeduceReturnType(clang::FunctionDecl*, clang::SourceLocation, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x147c6f0)
#​19 0x00007f80025a981b clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRefclang::SourceLocation, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x118981b)
#​20 0x00007f80027d7250 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x13b7250)
#​21 0x00007f80027dd875 clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x13bd875)
#​22 0x00007f80025c3aea clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x11a3aea)
#​23 0x00007f8001d984c1 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9784c1)
#​24 0x00007f8001d995c4 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9795c4)
#​25 0x00007f8001d97371 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x977371)
#​26 0x00007f8001d95c73 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x975c73)
#​27 0x00007f8001d7d8fd clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext, clang::ParsedAttributes&, llvm::SmallVectorImplclang::DeclaratorChunk::ParamInfo&, clang::SourceLocation&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x95d8fd)
#​28 0x00007f8001d7b135 clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x95b135)
#​29 0x00007f8001d79396 clang::Parser::ParseDirectDeclarator(clang::Declarator&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x959396)
#​30 0x00007f8001d772b3 clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::)(clang::Declarator&)) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9572b3)
#​31 0x00007f8001d6d61b clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation
, clang::Parser::ForRangeInit*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x94d61b)
#​32 0x00007f8001e0a91d clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9ea91d)
#​33 0x00007f8001e0a32c clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9ea32c)
#​34 0x00007f8001e094cf clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9e94cf)
#​35 0x00007f8001e07cbf clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9e7cbf)
#​36 0x00007f8001e076d7 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9e76d7)
#​37 0x00007f8001d58ce7 clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x938ce7)
#​38 0x00007f80032ee068 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1ece068)
#​39 0x00007f800327bd21 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1e5bd21)
#​40 0x00007f8003350452 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1f30452)
#​41 0x0000000000412782 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-12/bin/clang+0x412782)
#​42 0x0000000000410afe (/usr/lib/llvm-12/bin/clang+0x410afe)
#​43 0x000000000041090e main (/usr/lib/llvm-12/bin/clang+0x41090e)
#​44 0x00007f7ffb7170b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3
#​45 0x000000000040dcbe _start (/usr/lib/llvm-12/bin/clang+0x40dcbe)

Crash reproducer for Ubuntu clang version 12.0.0-++20210316012635+00441b8f4e5b-1exp120210316123347.61

Driver args: "--driver-mode=g++" "-D" "CMAKE_INTDIR="Debug"" "-I" "../tests/src" "-I" "_deps/ut-src/include" "-I" "../src" "-g" "-Wall" "-Wextra" "-Wshadow" "-Wno-error=shadow" "-Wnon-virtual-dtor" "-Wold-style-cast" "-Wcast-align" "-Wunused" "-Woverloaded-virtual" "-Wpedantic" "-Wconversion" "-Wsign-conversion" "-Wnull-dereference" "-Wdouble-promotion" "-Wformat=2" "-Werror" "-stdlib=libc++" "-std=c++20" "-MD" "-MT" "tests/src/CMakeFiles/ToolsLibrary_random_test.dir/Debug/random_test.cpp.o" "-MF" "tests/src/CMakeFiles/ToolsLibrary_random_test.dir/Debug/random_test.cpp.o.d" "-o" "tests/src/CMakeFiles/ToolsLibrary_random_test.dir/Debug/random_test.cpp.o" "-c" "../tests/src/random_test.cpp"

Original command: "/usr/lib/llvm-12/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "random_test.cpp" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-fno-split-dwarf-inlining" "-debug-info-kind=limited" "-dwarf-version=4" "-debugger-tuning=gdb" "-resource-dir" "/usr/lib/llvm-12/lib/clang/12.0.0" "-dependency-file" "tests/src/CMakeFiles/ToolsLibrary_random_test.dir/Debug/random_test.cpp.o.d" "-MT" "tests/src/CMakeFiles/ToolsLibrary_random_test.dir/Debug/random_test.cpp.o" "-sys-header-deps" "-D" "CMAKE_INTDIR="Debug"" "-I" "../tests/src" "-I" "_deps/ut-src/include" "-I" "../src" "-internal-isystem" "/usr/lib/llvm-12/bin/../include/c++/v1" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/llvm-12/lib/clang/12.0.0/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-Wall" "-Wextra" "-Wshadow" "-Wno-error=shadow" "-Wnon-virtual-dtor" "-Wold-style-cast" "-Wcast-align" "-Wunused" "-Woverloaded-virtual" "-Wpedantic" "-Wconversion" "-Wsign-conversion" "-Wnull-dereference" "-Wdouble-promotion" "-Wformat=2" "-Werror" "-std=c++20" "-fdeprecated-macro" "-fdebug-compilation-dir" "/mnt/d/dev/ToolsLibrary/build" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fno-implicit-modules" "-fcxx-exceptions" "-fexceptions" "-faddrsig" "-o" "tests/src/CMakeFiles/ToolsLibrary_random_test.dir/Debug/random_test.cpp.o" "-x" "c++" "../tests/src/random_test.cpp"

"/usr/lib/llvm-12/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "random_test.cpp" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-fno-split-dwarf-inlining" "-debug-info-kind=limited" "-dwarf-version=4" "-debugger-tuning=gdb" "-sys-header-deps" "-D" "CMAKE_INTDIR="Debug"" "-Wall" "-Wextra" "-Wshadow" "-Wno-error=shadow" "-Wnon-virtual-dtor" "-Wold-style-cast" "-Wcast-align" "-Wunused" "-Woverloaded-virtual" "-Wpedantic" "-Wconversion" "-Wsign-conversion" "-Wnull-dereference" "-Wdouble-promotion" "-Wformat=2" "-Werror" "-std=c++20" "-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fno-implicit-modules" "-fcxx-exceptions" "-fexceptions" "-faddrsig" "-x" "c++" "random_test-7f79f0.cpp"

@Sebanisu
Copy link
Author

Issue opened about this crash related to this:
Sebanisu/ToolsLibrary#7
Code:
https://github.com/Sebanisu/ToolsLibrary/blob/main/tests/src/random_test.cpp
https://github.com/Sebanisu/ToolsLibrary/blob/main/src/tl/random.hpp
I am unsure if you want this stuff. Let me know if you need more info.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Mar 26, 2021

Thanks for the reduced testcase! Slightly unreduced back to nearly-valid code:

void f(auto long_name = []<int = 0>() { long_name2; } ());

The explicit template parameter list seems to be necessary here; a generic lambda using (auto) doesn't trigger this.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

2 participants