[llvm-bugs] [Bug 46548] New: Clang crash in clang/lib/AST/Decl.cpp:1473: clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *, clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage() == D->getCachedLinkage()' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 1 22:35:01 PDT 2020


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

            Bug ID: 46548
           Summary: Clang crash in clang/lib/AST/Decl.cpp:1473:
                    clang::LinkageInfo
                    clang::LinkageComputer::getLVForDecl(const
                    clang::NamedDecl *, clang::LVComputationKind):
                    Assertion `!Old || Old->getCachedLinkage() ==
                    D->getCachedLinkage()' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: compile-fail
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi, there.

This case, bug.cc, is totally a valid code but makes clang-trunk crashed.

$cat bug.cc
inline namespace {
namespace a {
    template <int> void c();
}
} // namespace
namespace a {
template <int> void c();
}

$clang++ bug.cc
clang-11: /home/haoxin/compilers/llvm-project/clang/lib/AST/Decl.cpp:1473:
clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::Named
Decl *, clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage()
== D->getCachedLinkage()' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/home/haoxin/compilers/llvm-project/build/bin/clang-11 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disabl
e-free -main-file-name bug.cc -mrelocation-model static -mframe-pointer=all
-fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -ta
rget-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining
-debugger-tuning=gdb -resource-dir
/home/haoxin/compilers/llvm-project/build/lib/clang/1
1.0.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../in
clude/x86_64-linux-gnu/c++/10 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem /usr/l
ib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward
-internal-isystem /usr/local/include -internal-isystem
/home/haoxin/compilers/llvm-pro
ject/build/lib/clang/11.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isys
tem /usr/include -fdeprecated-macro -fdebug-compilation-dir
/home/haoxin/bitbucket/scg-backup-bitbucket/ice-test/5/creduce -ferror-limit 19
-fgnuc-ve
rsion=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o
/tmp/bug-be04dc.o -x c++ bug.cc 
1.      bug.cc:7:24: current parser token ';'
2.      bug.cc:6:1: parsing namespace 'a'
 #0 0x00000000026f36c4 PrintStackTraceSignalHandler(void*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x26f36c4)
 #1 0x00000000026f12be llvm::sys::RunSignalHandlers()
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x26f12be)
 #2 0x00000000026f39e5 SignalHandler(int)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x26f39e5)
 #3 0x00007f2cab6a4890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f2caa102e97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f2caa104801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f2caa0f439a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f2caa0f4412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x00000000049717e6 clang::LinkageComputer::getLVForDecl(clang::NamedDecl
const*, clang::LVComputationKind) (/home/haoxin/compilers/llvm-project/b
uild/bin/clang-11+0x49717e6)
 #9 0x0000000004973f4e clang::NamedDecl::getLinkageInternal() const
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x4973f4e)
#10 0x000000000401f3b7 clang::Sema::ActOnFunctionDeclarator(clang::Scope*,
clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::Lo
okupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x401f3b7)
#11 0x00000000040187d8 clang::Sema::HandleDeclarator(clang::Scope*,
clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>)
(/home/
haoxin/compilers/llvm-project/build/bin/clang-11+0x40187d8)
#12 0x0000000004525c08 clang::Sema::ActOnTemplateDeclarator(clang::Scope*,
llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::Declarator&) 
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x4525c08)
#13 0x0000000003e0c682
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clan
g::Parser::ForRangeInit*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e0c682)
#14 0x0000000003e0d85b
clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&) (/home/haoxin/com
pilers/llvm-project/build/bin/clang-11+0x3e0d85b)
#15 0x0000000003e9e110
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e9e110)
#16 0x0000000003e9ce00
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e9ce00)
#17 0x0000000003e9c70e
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e9c70e)
#18 0x0000000003e05ba0
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e05ba0)
#19 0x0000000003ded86a
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3ded86a)
#20 0x0000000003e1f92b
clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo,
4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&,
clang::BalancedDelimiterTracker&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e1f92b)
#21 0x0000000003e1f258 clang::Parser::ParseNamespace(clang::DeclaratorContext,
clang::SourceLocation&, clang::SourceLocation)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e1f258)
#22 0x0000000003e05d67
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3e05d67)
#23 0x0000000003ded86a
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3ded86a)
#24 0x0000000003dec28d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3dec28d)
#25 0x0000000003de770d clang::ParseAST(clang::Sema&, bool, bool)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x3de770d)
#26 0x0000000002ebc3f3 clang::FrontendAction::Execute()
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2ebc3f3)
#27 0x0000000002e539c3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2e539c3)
#28 0x0000000002f67532
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x2f67532)
#29 0x000000000095d060 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95d060)
#30 0x000000000095b12c ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95b12c)
#31 0x000000000095addf main
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x95addf)
#32 0x00007f2caa0e5b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#33 0x0000000000957eba _start
(/home/haoxin/compilers/llvm-project/build/bin/clang-11+0x957eba)
clang-11: error: unable to execute command: Aborted (core dumped)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.0.0 (https://github.com/llvm/llvm-project
b9306fd042ce1c11d84f05d2124dfdc65b8331fe)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-project/build/bin
clang-11: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg: /tmp/bug-2ea9d9.cpp
clang-11: note: diagnostic msg: /tmp/bug-2ea9d9.sh
clang-11: note: diagnostic msg: 

********************

$clang++ -v
clang version 11.0.0 (https://github.com/llvm/llvm-project
b9306fd042ce1c11d84f05d2124dfdc65b8331fe)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/haoxin/compilers/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64

-- 
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/20200702/c331203d/attachment.html>


More information about the llvm-bugs mailing list