Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang-11 crashes on the deal.ii project #46675

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR47706
Status NEW
Importance P enhancement
Reported by Yuri (yuri@tsoft.com)
Reported on 2020-10-01 12:31:36 -0700
Last modified on 2021-08-17 06:23:39 -0700
Version 11.0
Hardware PC FreeBSD
CC blitzrakete@gmail.com, dgregor@apple.com, dimitry@andric.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, riccibrun@gmail.com, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Crash dump:
* https://people.freebsd.org/~yuri/grid_generator-5bb0cd.cpp
* https://people.freebsd.org/~yuri/grid_generator-5bb0cd.sh

Project:
dealii: https://github.com/dealii/dealii version 9.1.1

Encountered while bjuilding the FreeBSD port math/deal.ii r542423 on FreeBSD 13-
CURRENT amd64.
Quuxplusone commented 3 years ago
The actual error is:

% clang -cc1 -triple x86_64-unknown-freebsd13.0 -emit-obj -disable-free -main-
file-name grid_generator.cc -mrelocation-model pic -pic-level 2 -mframe-
pointer=all -fno-rounding-math -mconstructor-aliases -munwind-tables -target-
cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -D BOOST_NO_AUTO_PTR -
O2 -Wall -Wextra -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wsuggest-
override -Wswitch -Wsynth -Wwrite-strings -Wno-deprecated-declarations -Wno-
psabi -Wfloat-conversion -Wno-unsupported-friend -Wno-undefined-var-template -
Wno-unused-local-typedefs -pedantic -std=c++17 -fdeprecated-macro -ferror-limit
19 -funroll-loops -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -
fexceptions -vectorize-loops -vectorize-slp -faddrsig -x c++ grid_generator-
5bb0cd.cpp
Didn't find this decl on its identifier's chain!
UNREACHABLE executed at /usr/src/contrib/llvm-
project/clang/lib/Sema/IdentifierResolver.cpp:82!
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the
crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang -cc1 -triple x86_64-unknown-freebsd13.0 -emit-
obj -disable-free -main-file-name grid_generator.cc -mrelocation-model pic -pic-
level 2 -mframe-pointer=all -fno-rounding-math -mconstructor-aliases -munwind-
tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -D
BOOST_NO_AUTO_PTR -O2 -Wall -Wextra -Woverloaded-virtual -Wpointer-arith -Wsign-
compare -Wsuggest-override -Wswitch -Wsynth -Wwrite-strings -Wno-deprecated-
declarations -Wno-psabi -Wfloat-conversion -Wno-unsupported-friend -Wno-
undefined-var-template -Wno-unused-local-typedefs -pedantic -std=c++17 -
fdeprecated-macro -ferror-limit 19 -funroll-loops -stack-protector 2 -fgnuc-
version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -
faddrsig -x c++ grid_generator-5bb0cd.cpp
1.      /usr/ports/math/deal.ii/work/dealii-
9.1.1/source/grid/grid_generator.cc:4037:3: current parser token 'template'
2.      /usr/ports/math/deal.ii/work/dealii-
9.1.1/source/grid/grid_generator.cc:31:1
<Spelling=/usr/ports/math/deal.ii/work/.build/include/deal.II/base/config.h:355:32>:
parsing namespace 'dealii'
3.      /usr/ports/math/deal.ii/work/dealii-
9.1.1/source/grid/grid_generator.cc:34:1: parsing namespace
'dealii::GridGenerator'
4.      /usr/ports/math/deal.ii/work/dealii-
9.1.1/source/grid/grid_generator.cc:3896:3: parsing function body
'dealii::GridGenerator::hyper_shell<3>'
#0 0x00000000041d47ce PrintStackTrace /usr/src/contrib/llvm-
project/llvm/lib/Support/Unix/Signals.inc:564:13
#1 0x00000000041d2a25 RunSignalHandlers /usr/src/contrib/llvm-
project/llvm/lib/Support/Signals.cpp:69:18
#2 0x00000000041d4ec0 SignalHandler /usr/src/contrib/llvm-
project/llvm/lib/Support/Unix/Signals.inc:0:3
#3 0x000000080568fb90 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
Quuxplusone commented 3 years ago
Minimized test case (this took quite a while to reduce!):

// clang -cc1 -triple x86_64-- -S -O1 -std=c++17 grid_generator-min.cpp
template <int> struct a {};
namespace b {
template <int c>
void e(a<c> &, const int &center, double, double, unsigned, bool = 0);
template <int c> void d(a<c> &, double, double, double, unsigned, bool);
} // namespace b
struct g {
  g(int center = 0);
  int center;
};
namespace b {
template <> void e(a<3> &, const int &f, double, double, unsigned, bool) {
  a<3> h;
  e(h, 0, 0, 0, 0);
}
template <> void d(a<0> &, double, double, double, unsigned, bool);
} // namespace b

Bisection shows this bug was introduced with
https://reviews.llvm.org/rGa5569f089844:

commit a5569f089844209dbea2e3241460173d7b6b1420 (HEAD)
Author: Richard Smith <richard@metafoo.co.uk>
Date:   Thu Jul 9 14:57:30 2020 -0700

    Push parameters into the local instantiation scope before instantiating
    a default argument.

    Default arguments can (after recent language changes) refer to
    parameters of the same function. Make sure they're added to the local
    instantiation scope before transforming a default argument so that we
    can remap such references to them properly.
Quuxplusone commented 3 years ago
This still asserts as of 2021-08-17 with llvmorg-14-init-1622-g8f8f9260a95f:

Starting program: /home/dim/obj/llvm-llvmorg-14-init-1622-g8f8f9260a95f-
freebsd14-amd64-ninja-clang-dbg-1/bin/clang -cc1 -triple x86_64-- -S -O1 -
std=c++17 grid_generator-min.cpp
Didn't find this decl on its identifier's chain!
UNREACHABLE executed at /share/dim/src/llvm/llvm-
project/clang/lib/Sema/IdentifierResolver.cpp:82!

Program received signal SIGABRT, Aborted.
thr_kill () at thr_kill.S:4
4       thr_kill.S: No such file or directory.
(gdb) bt
#0  thr_kill () at thr_kill.S:4
#1  0x000000080b8c2fc4 in __raise (s=s@entry=6) at
/usr/src/lib/libc/gen/raise.c:52
#2  0x000000080b9778e9 in abort () at /usr/src/lib/libc/stdlib/abort.c:67
#3  0x0000000005380c30 in llvm::llvm_unreachable_internal (msg=0xdf2c28 "Didn't
find this decl on its identifier's chain!", file=0xe6a192
"/share/dim/src/llvm/llvm-project/clang/lib/Sema/IdentifierResolver.cpp",
line=82) at /share/dim/src/llvm/llvm-
project/llvm/lib/Support/ErrorHandling.cpp:213
#4  0x00000000090255b9 in clang::IdentifierResolver::IdDeclInfo::RemoveDecl
(this=0x80c8057c8, D=0x80c802bd0) at /share/dim/src/llvm/llvm-
project/clang/lib/Sema/IdentifierResolver.cpp:82
#5  0x0000000009025d54 in clang::IdentifierResolver::RemoveDecl
(this=0x80c27a4b8, D=0x80c802bd0) at /share/dim/src/llvm/llvm-
project/clang/lib/Sema/IdentifierResolver.cpp:225
#6  0x00000000092f334d in clang::Sema::ActOnPopScope (this=0x80c279800,
Loc=..., S=0x80c22bfc0) at /share/dim/src/llvm/llvm-
project/clang/lib/Sema/SemaDecl.cpp:2003
#7  0x0000000008f157c7 in clang::Parser::ExitScope (this=0x80c333800) at
/share/dim/src/llvm/llvm-project/clang/lib/Parse/Parser.cpp:420
#8  0x0000000008f206aa in clang::Parser::ParseScope::Exit (this=0x7fffffff8e00)
at /share/dim/src/llvm/llvm-project/clang/include/clang/Parse/Parser.h:1107
#9  0x0000000008fc3b40 in clang::Parser::ParseFunctionStatementBody
(this=0x80c333800, Decl=0x80c802f38, BodyScope=...) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/ParseStmt.cpp:2284
#10 0x0000000008f1ace8 in clang::Parser::ParseFunctionDefinition
(this=0x80c333800, D=..., TemplateInfo=..., LateParsedAttrs=0x7fffffff9300) at
/share/dim/src/llvm/llvm-project/clang/lib/Parse/Parser.cpp:1377
#11 0x0000000008ff3161 in clang::Parser::ParseSingleDeclarationAfterTemplate
(this=0x80c333800, Context=clang::DeclaratorContext::File, TemplateInfo=...,
DiagsFromTParams=..., DeclEnd=..., AccessAttrs=..., AS=clang::AS_none) at
/share/dim/src/llvm/llvm-project/clang/lib/Parse/ParseTemplate.cpp:345
#12 0x0000000008ff1d94 in
clang::Parser::ParseTemplateDeclarationOrSpecialization (this=0x80c333800,
Context=clang::DeclaratorContext::File, DeclEnd=..., AccessAttrs=...,
AS=clang::AS_none) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/ParseTemplate.cpp:169
#13 0x0000000008ff1784 in clang::Parser::ParseDeclarationStartingWithTemplate
(this=0x80c333800, Context=clang::DeclaratorContext::File, DeclEnd=...,
AccessAttrs=..., AS=clang::AS_none) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/ParseTemplate.cpp:46
#14 0x0000000008f58c8b in clang::Parser::ParseDeclaration (this=0x80c333800,
Context=clang::DeclaratorContext::File, DeclEnd=..., attrs=...,
DeclSpecStart=0x0) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/ParseDecl.cpp:1729
#15 0x0000000008f1880d in clang::Parser::ParseExternalDeclaration
(this=0x80c333800, attrs=..., DS=0x0) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/Parser.cpp:909
#16 0x0000000008f2a143 in clang::Parser::ParseInnerNamespace (this=0x80c333800,
InnerNSs=..., index=0, InlineLoc=..., attrs=..., Tracker=...) at
/share/dim/src/llvm/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:246
#17 0x0000000008f29b5a in clang::Parser::ParseNamespace (this=0x80c333800,
Context=clang::DeclaratorContext::File, DeclEnd=..., InlineLoc=...) at
/share/dim/src/llvm/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:224
#18 0x0000000008f58e25 in clang::Parser::ParseDeclaration (this=0x80c333800,
Context=clang::DeclaratorContext::File, DeclEnd=..., attrs=...,
DeclSpecStart=0x0) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/ParseDecl.cpp:1742
#19 0x0000000008f1880d in clang::Parser::ParseExternalDeclaration
(this=0x80c333800, attrs=..., DS=0x0) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/Parser.cpp:909
#20 0x0000000008f1707b in clang::Parser::ParseTopLevelDecl (this=0x80c333800,
Result=..., IsFirstDecl=false) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/Parser.cpp:720
#21 0x0000000008f122f4 in clang::ParseAST (S=..., PrintStats=false,
SkipFunctionBodies=false) at /share/dim/src/llvm/llvm-
project/clang/lib/Parse/ParseAST.cpp:158
#22 0x000000000663a79c in clang::ASTFrontendAction::ExecuteAction
(this=0x80c221380) at /share/dim/src/llvm/llvm-
project/clang/lib/Frontend/FrontendAction.cpp:1058
#23 0x0000000006801a60 in clang::CodeGenAction::ExecuteAction
(this=0x80c221380) at /share/dim/src/llvm/llvm-
project/clang/lib/CodeGen/CodeGenAction.cpp:1044
#24 0x000000000663a19c in clang::FrontendAction::Execute (this=0x80c221380) at
/share/dim/src/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:951
#25 0x0000000006573266 in clang::CompilerInstance::ExecuteAction
(this=0x80c31f000, Act=...) at /share/dim/src/llvm/llvm-
project/clang/lib/Frontend/CompilerInstance.cpp:974
#26 0x00000000067f33ae in clang::ExecuteCompilerInvocation (Clang=0x80c31f000)
at /share/dim/src/llvm/llvm-
project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278
#27 0x000000000363eaf3 in cc1_main (Argv=..., Argv0=0x7fffffffe768
"/home/dim/obj/llvm-llvmorg-14-init-1622-g8f8f9260a95f-freebsd14-amd64-ninja-
clang-dbg-1/bin/clang", MainAddr=0x362fd90 <GetExecutablePath(char const*,
bool)>) at /share/dim/src/llvm/llvm-project/clang/tools/driver/cc1_main.cpp:246
#28 0x000000000363122b in ExecuteCC1Tool (ArgV=...) at /share/dim/src/llvm/llvm-
project/clang/tools/driver/driver.cpp:338
#29 0x0000000003630475 in main (Argc=8, Argv=0x7fffffffe3e0) at
/share/dim/src/llvm/llvm-project/clang/tools/driver/driver.cpp:409
(gdb) frame 4
#4  0x00000000090255b9 in clang::IdentifierResolver::IdDeclInfo::RemoveDecl
(this=0x80c8057c8, D=0x80c802bd0) at /share/dim/src/llvm/llvm-
project/clang/lib/Sema/IdentifierResolver.cpp:82
82        llvm_unreachable("Didn't find this decl on its identifier's chain!");
(gdb) print Decls
$1 = {<llvm::SmallVectorImpl<clang::NamedDecl*>> =
{<llvm::SmallVectorTemplateBase<clang::NamedDecl*, true>> =
{<llvm::SmallVectorTemplateCommon<clang::NamedDecl*, void>> =
{<llvm::SmallVectorBase<unsigned int>> = {BeginX = 0x80c8057d8, Size = 0,
Capacity = 2}, <No data fields>}, static TakesParamByValue = true}, <No data
fields>}, <llvm::SmallVectorStorage<clang::NamedDecl*, 2>> = {InlineElts = "
(\200\f\b\000\000\000P&\200\f\b\000\000"}, <No data fields>}

It seems as if Decls is just empty on entry of IdDeclInfo::RemoveDecl() ?