Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Assertion failed: (Loc.isValid() && "point of instantiation must be valid!"), #25667

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR25668
Status NEW
Importance P normal
Reported by Dmitry Marakasov (amdmi3@amdmi3.ru)
Reported on 2015-11-29 14:17:22 -0800
Last modified on 2020-11-04 12:45:01 -0800
Version 3.7
Hardware PC FreeBSD
CC akim.demaille@gmail.com, hokein@google.com, llvm-bugs@lists.llvm.org, zahira.ammarguellat@intel.com
Fixed by commit(s)
Attachments coins-aa5424.cpp.gz (479278 bytes, application/gzip)
coins-aa5424.sh (2499 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 15361
Compressed source

Clang 3.7.0 from FreeBSD-current base system crashes on my code:

---
FreeBSD clang version 3.7.0 (tags/RELEASE_370/final 246257) 20150906
Target: x86_64-unknown-freebsd11.0
Thread model: posix
---
Assertion failed: (Loc.isValid() && "point of instantiation must be valid!"),
function setPointOfInstantiation, file
/usr/src/lib/clang/libclangsema/../../../contrib/llvm/tools/clang/include/clang/AST/DeclTemplate.h,
line 1606.
CC: error: unable to execute command: Abort trap
CC: error: clang frontend command failed due to signal (use -v to see
invocation)
FreeBSD clang version 3.7.0 (tags/RELEASE_370/final 246257) 20150906
Target: x86_64-unknown-freebsd11.0
Thread model: posix
CC: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed
source, and associated run script.
CC: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
CC: note: diagnostic msg: /tmp/coins-a35b73.cpp
CC: note: diagnostic msg: /tmp/coins-a35b73.sh
CC: note: diagnostic msg:

********************
*** Error code 254

Stop.
make[2]: stopped in /home/amdmi3/projects/software/hoverboard-sdl/build
*** Error code 1

Stop.
make[1]: stopped in /home/amdmi3/projects/software/hoverboard-sdl/build
*** Error code 1

Stop.
make: stopped in /home/amdmi3/projects/software/hoverboard-sdl/build
---

Complete source and run script attached.
Quuxplusone commented 9 years ago

Attached coins-aa5424.cpp.gz (479278 bytes, application/gzip): Compressed source

Quuxplusone commented 9 years ago

Attached coins-aa5424.sh (2499 bytes, application/octet-stream): Run script

Quuxplusone commented 8 years ago
A whole crash log:

#0 0x0000000002d89487 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/llvm/build/bin/clang-3.8+0x2d89487)
#1 0x0000000002d8979c PrintStackTraceSignalHandler(void*)
(/usr/local/llvm/build/bin/clang-3.8+0x2d8979c)
#2 0x0000000002d87de9 llvm::sys::RunSignalHandlers()
(/usr/local/llvm/build/bin/clang-3.8+0x2d87de9)
#3 0x0000000002d88efd SignalHandler(int) (/usr/local/llvm/build/bin/clang-
3.8+0x2d88efd)
#4 0x00007f56bec38340 __restore_rt (/lib/x86_64-linux-
gnu/libpthread.so.0+0x10340)
#5 0x00007f56bde60cc9 gsignal /build/eglibc-3GlaMS/eglibc-
2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#6 0x00007f56bde640d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#7 0x00007f56bde59b86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-
2.19/assert/assert.c:92:0
#8 0x00007f56bde59c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#9 0x000000000415f6ed
clang::ClassTemplateSpecializationDecl::setPointOfInstantiation(clang::SourceLocation)
(/usr/local/llvm/build/bin/clang-3.8+0x415f6ed)
#10 0x000000000493706b clang::Sema::InstantiateClass(clang::SourceLocation,
clang::CXXRecordDecl*, clang::CXXRecordDecl*,
clang::MultiLevelTemplateArgumentList const&,
clang::TemplateSpecializationKind, bool) (/usr/local/llvm/build/bin/clang-
3.8+0x493706b)
#11 0x0000000004938b1e
clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation,
clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind,
bool) (/usr/local/llvm/build/bin/clang-3.8+0x4938b1e)
#12 0x00000000049d914a
clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType,
clang::Sema::TypeDiagnoser*) (/usr/local/llvm/build/bin/clang-3.8+0x49d914a)
#13 0x00000000049d86b1 clang::Sema::RequireCompleteType(clang::SourceLocation,
clang::QualType, clang::Sema::TypeDiagnoser&) (/usr/local/llvm/build/bin/clang-
3.8+0x49d86b1)
#14 0x000000000457e00c clang::Sema::CheckCallReturnType(clang::QualType,
clang::SourceLocation, clang::CallExpr*, clang::FunctionDecl*)
(/usr/local/llvm/build/bin/clang-3.8+0x457e00c)
#15 0x00000000047e5297
clang::Sema::CreateOverloadedArraySubscriptExpr(clang::SourceLocation,
clang::SourceLocation, clang::Expr*, clang::Expr*)
(/usr/local/llvm/build/bin/clang-3.8+0x47e5297)
#16 0x0000000004551280 clang::Sema::ActOnArraySubscriptExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, clang::Expr*, clang::SourceLocation)
(/usr/local/llvm/build/bin/clang-3.8+0x4551280)
#17 0x00000000046347de clang::TreeTransform<(anonymous
namespace)::TransformTypos>::RebuildArraySubscriptExpr(clang::Expr*,
clang::SourceLocation, clang::Expr*, clang::SourceLocation)
(/usr/local/llvm/build/bin/clang-3.8+0x46347de)
#18 0x0000000004624ee3 clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformArraySubscriptExpr(clang::ArraySubscriptExpr*)
(/usr/local/llvm/build/bin/clang-3.8+0x4624ee3)
#19 0x0000000004621c31 clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformExpr(clang::Expr*)
(/usr/local/llvm/build/bin/clang-3.8+0x4621c31)
#20 0x000000000461ef55 (anonymous
namespace)::TransformTypos::TryTransform(clang::Expr*)
(/usr/local/llvm/build/bin/clang-3.8+0x461ef55)
#21 0x000000000461f2f8 (anonymous
namespace)::TransformTypos::Transform(clang::Expr*)
(/usr/local/llvm/build/bin/clang-3.8+0x461f2f8)
#22 0x000000000461fbe6 clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*, llvm::function_ref<clang::ActionResult<clang::Expr*, true>
(clang::Expr*)>) (/usr/local/llvm/build/bin/clang-3.8+0x461fbe6)
#23 0x00000000040912cf clang::Parser::ParseBraceInitializer()
(/usr/local/llvm/build/bin/clang-3.8+0x40912cf)
#24 0x0000000004042c48
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/local/llvm/build/bin/clang-3.8+0x4042c48)
#25 0x00000000040414ea clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/llvm/build/bin/clang-3.8+0x40414ea)
#26 0x0000000004025696
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/llvm/build/bin/clang-3.8+0x4025696)
#27 0x0000000004025787
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/llvm/build/bin/clang-3.8+0x4025787)
#28 0x0000000004024ebd
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/llvm/build/bin/clang-3.8+0x4024ebd)
#29 0x00000000040243a4
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/llvm/build/bin/clang-3.8+0x40243a4)
#30 0x000000000401cf12 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/llvm/build/bin/clang-3.8+0x401cf12)
#31 0x000000000341dab6 clang::ASTFrontendAction::ExecuteAction()
(/usr/local/llvm/build/bin/clang-3.8+0x341dab6)
#32 0x000000000341d57b clang::FrontendAction::Execute()
(/usr/local/llvm/build/bin/clang-3.8+0x341d57b)
#33 0x00000000033d866c
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/llvm/build/bin/clang-3.8+0x33d866c)
#34 0x0000000003512301
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/llvm/build/bin/clang-3.8+0x3512301)
#35 0x0000000001634bee cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/llvm/build/bin/clang-3.8+0x1634bee)
#36 0x000000000162bd84 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef) (/usr/local/llvm/build/bin/clang-3.8+0x162bd84)
#37 0x000000000162c853 main (/usr/local/llvm/build/bin/clang-3.8+0x162c853)
#38 0x00007f56bde4bec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-
2.19/csu/libc-start.c:321:0
#39 0x0000000001628119 _start (/usr/local/llvm/build/bin/clang-3.8+0x1628119)
S

And a minimal testcase:

// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 %s

template <class> class A {};
class {
  A<int> operator[](int);
} mask_ {
  mask[2];
};
Quuxplusone commented 8 years ago
I have a similar problem, and I don't understand what workaround would work.
The code compiles fine with G++, and Clang++ 3.5, but Clang++ 3.6, 3.7, 3.8 and
3.9 die on it.

Any clues of possible workarounds?

Assertion failed: (Loc.isValid() && "point of instantiation must be valid!"),
function setPointOfInstantiation, file
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_llvm-
3.6/clang-3.6/work/llvm-
3.6.2.src/tools/clang/lib/Sema/../../include/clang/AST/DeclTemplate.h, line
1520.
0  libLLVM-3.6.dylib        0x000000010c592195
llvm::sys::PrintStackTrace(__sFILE*) + 57
1  libLLVM-3.6.dylib        0x000000010c5926eb SignalHandler(int) + 217
2  libsystem_platform.dylib 0x00007fff99cf852a _sigtramp + 26
3  libLLVM-3.6.dylib        0x000000010d0f3e74 llvm::InlineCostAnalysis::ID +
119946
4  libLLVM-3.6.dylib        0x000000010c59257a abort + 22
5  libLLVM-3.6.dylib        0x000000010c592564 abort + 0
6  clang                    0x000000010a769301
clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*,
clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&,
clang::TemplateSpecializationKind, bool) + 2251
7  clang                    0x000000010a76a206
clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation,
clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind,
bool) + 1566
8  clang                    0x000000010a7b2ced
clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType,
clang::Sema::TypeDiagnoser&) + 489
9  clang                    0x000000010a7b2a4d
clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType,
clang::Sema::TypeDiagnoser&) + 21
10 clang                    0x000000010a7aa6cd
clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType,
unsigned int) + 37
11 clang                    0x000000010a4c3dc0 TryStaticDowncast(clang::Sema&,
clang::CanQual<clang::Type>, clang::CanQual<clang::Type>, bool,
clang::SourceRange const&, clang::QualType, clang::QualType, unsigned int&,
clang::CastKind&, llvm::SmallVector<clang::CXXBaseSpecifier*, 4u>&) + 83
12 clang                    0x000000010a4c2d1b TryStaticCast(clang::Sema&,
clang::ActionResult<clang::Expr*, true>&, clang::QualType,
clang::Sema::CheckedConversionKind, clang::SourceRange const&, unsigned int&,
clang::CastKind&, llvm::SmallVector<clang::CXXBaseSpecifier*, 4u>&, bool) + 289
13 clang                    0x000000010a4bd3ba
clang::Sema::BuildCXXNamedCast(clang::SourceLocation, clang::tok::TokenKind,
clang::TypeSourceInfo*, clang::Expr*, clang::SourceRange, clang::SourceRange) +
842
14 clang                    0x000000010a589ad3 CastForMoving(clang::Sema&,
clang::Expr*, clang::QualType) + 127
15 clang                    0x000000010a563907
BuildImplicitBaseInitializer(clang::Sema&, clang::CXXConstructorDecl*,
ImplicitInitializerKind, clang::CXXBaseSpecifier*, bool,
clang::CXXCtorInitializer*&) + 1396
16 clang                    0x000000010a562da7
clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool,
llvm::ArrayRef<clang::CXXCtorInitializer*>) + 1931
17 clang                    0x000000010a574108
clang::Sema::DefineInheritingConstructor(clang::SourceLocation,
clang::CXXConstructorDecl*) + 148
18 clang                    0x000000010a5dca3f
clang::Sema::MarkFunctionReferenced(clang::SourceLocation,
clang::FunctionDecl*, bool) + 725
19 clang                    0x000000010a66d3b9
PerformConstructorInitialization(clang::Sema&, clang::InitializedEntity const&,
clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>,
clang::InitializationSequence::Step const&, bool&, bool, bool,
clang::SourceLocation, clang::SourceLocation) + 577
20 clang                    0x000000010a668bea
clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity
const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>,
clang::QualType*) + 4552
21 clang                    0x000000010a612081
clang::Sema::BuildCXXTypeConstructExpr(clang::TypeSourceInfo*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation) + 1059
22 clang                    0x000000010a772b35 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCXXUnresolvedConstructExpr(clang::CXXUnresolvedConstructExpr*)
+ 263
23 clang                    0x000000010a769bb7
clang::Sema::SubstInitializer(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&, bool) + 67
24 clang                    0x000000010a795bbe
clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*,
clang::MultiLevelTemplateArgumentList const&) + 238
25 clang                    0x000000010a78b7d6
clang::Sema::BuildVariableInstantiation(clang::VarDecl*, clang::VarDecl*,
clang::MultiLevelTemplateArgumentList const&,
llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*,
clang::DeclContext*, clang::LocalInstantiationScope*, bool) + 1322
26 clang                    0x000000010a78af50
clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool) + 512
27 clang                    0x000000010a79123e
clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*,
clang::MultiLevelTemplateArgumentList const&) + 166
28 clang                    0x000000010a78332c (anonymous
namespace)::TemplateInstantiator::TransformDefinition(clang::SourceLocation,
clang::Decl*) + 32
29 clang                    0x000000010a780f74 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*) + 120
30 clang                    0x000000010a77ebec clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*,
bool) + 158
31 clang                    0x000000010a76ac97
clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList
const&) + 71
32 clang                    0x000000010a794a3a
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 1896
33 clang                    0x000000010a79556c
clang::Sema::PerformPendingInstantiations(bool) + 320
34 clang                    0x000000010a4aa3e8
clang::Sema::ActOnEndOfTranslationUnit() + 586
35 clang                    0x000000010a472ce4
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 188
36 clang                    0x000000010a417580 clang::ParseAST(clang::Sema&,
bool, bool) + 335
37 clang                    0x000000010a179aed clang::FrontendAction::Execute()
+ 67
38 clang                    0x000000010a155fb0
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 556
39 clang                    0x000000010a126497
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3935
40 clang                    0x000000010a11edca cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 1074
41 clang                    0x000000010a124a32 main + 8349
42 libdyld.dylib            0x00007fff97b275ad start + 1
Stack dump:
0.  Program arguments: /opt/local/libexec/llvm-3.6/bin/clang -cc1 -triple x86_64-
apple-macosx10.11.0 -emit-obj -mrelax-all -disable-free -main-file-name
foo.stdout.erebus.lrde.epita.fr.7382.1mhpuP.ii -mrelocation-model pic -pic-
level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -
target-cpu core2 -target-linker-version 253.6 -gdwarf-2 -dwarf-column-info -
coverage-file /private/tmp/foo.7362.o -resource-dir /opt/local/libexec/llvm-
3.6/bin/../lib/clang/3.6.2 -std=c++1z -fdeprecated-macro -fdebug-compilation-
dir /private/tmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -
mstackrealign -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-
signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-
option -o foo.7362.o -x c++-cpp-output
/Users/akim/.ccache/tmp/foo.stdout.erebus.lrde.epita.fr.7382.1mhpuP.ii
1.  <eof> parser at end of file
2.  /Users/akim/src/lrde/2/vcsn/algos/random-weight.hh:15:3: instantiating
function definition 'random_weight'
clang: error: unable to execute command: Illegal instruction: 4
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.6.2 (tags/RELEASE_362/final)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.
Quuxplusone commented 4 years ago
Here is a small test case that reproduces the issue.

$ cat t.cpp
template < typename T >
struct z {
  static void aj() {
    T f;
#pragma omp target map(f)
    ;
  }
};

template < typename > class ar {};
template < int > struct as {};

template class z< ar<as<4>> >;

$ clang -std=c++17 -fiopenmp -c t.cpp

Assertion failed: Loc.isValid() && "point of instantiation must be valid!",
file clang\include\clang/AST/DeclTemplate.h, line 1940
PLEASE submit a bug report [] and include the crash backtrace, preprocessed
source, and associated run script.
Stack dump:
0.      Program arguments: clang -std=c++17 -fopenmp -c t.cpp
1.      <eof> parser at end of file
2.      t.cpp:3:15: instantiating function definition 'z<ar<as<4>>>::aj'
...