Open Quuxplusone opened 9 years ago
Attached segfault_reproduction.cpp
(575 bytes, text/x-c++src): Source
Error Message:
clang:
/home/mascholz/Software/llvm/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h:2747:
void clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList
&, const T *, CallExpr::const_arg_iterator, CallExpr::const_arg_iterator, const
clang::FunctionDecl *, unsigned int, bool) [T = clang::FunctionProtoType]:
Assertion `getContext() .getCanonicalType(ArgType.getNonReferenceType())
.getTypePtr() == getContext().getCanonicalType(ActualArgType).getTypePtr() &&
"type mismatch in call argument!"' failed.
0 clang 0x0000000002901ef8 llvm::sys::PrintStackTrace(_IO_FILE*) + 40
1 clang 0x000000000290354b
2 libpthread.so.0 0x00007f5e9d51d6d0
3 libc.so.6 0x00007f5e9c532877 gsignal + 55
4 libc.so.6 0x00007f5e9c533f68 abort + 328
5 libc.so.6 0x00007f5e9c52b7d6
6 libc.so.6 0x00007f5e9c52b882
7 clang 0x00000000009d45ee
8 clang 0x0000000000a35b18
9 clang 0x0000000000a357f9
clang::CodeGen::CodeGenFunction::EmitCXXMemberOrOperatorCall(clang::CXXMethodDecl
const*, llvm::Value*, clang::CodeGen::ReturnValueSlot, llvm::Value*,
llvm::Value*, clang::QualType, clang::CallExpr const*) + 249
10 clang 0x0000000000a367cd
clang::CodeGen::CodeGenFunction::EmitCXXMemberCallExpr(clang::CXXMemberCallExpr
const*, clang::CodeGen::ReturnValueSlot) + 2525
11 clang 0x0000000000a2b6f5
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot) + 261
12 clang 0x0000000000a5497e
13 clang 0x0000000000a4d220
14 clang 0x0000000000a44450
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 96
15 clang 0x0000000000a17de9
clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*,
clang::CodeGen::AggValueSlot, bool) + 249
16 clang 0x0000000000a17ce6
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) + 54
17 clang 0x00000000009231f8
clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) + 440
18 clang 0x000000000092c26b
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 91
19 clang 0x00000000009403ad
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*) + 93
20 clang 0x0000000000940985
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1205
21 clang 0x000000000094fa57
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 1511
22 clang 0x000000000094c868
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 296
23 clang 0x000000000094e66b
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 811
24 clang 0x0000000000951411
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 209
25 clang 0x00000000008f59ef
26 clang 0x00000000008ed457
27 clang 0x0000000000ae8863 clang::ParseAST(clang::Sema&, bool, bool)
+ 387
28 clang 0x00000000008ec4fc clang::CodeGenAction::ExecuteAction() +
204
29 clang 0x00000000006fec5e clang::FrontendAction::Execute() + 62
30 clang 0x00000000006d185c
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 892
31 clang 0x00000000006b4b8a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 3050
32 clang 0x00000000006ab451 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 657
33 clang 0x00000000006b3293 main + 12259
34 libc.so.6 0x00007f5e9c51ed65 __libc_start_main + 245
35 clang 0x00000000006ab0f9
Stack dump:
0. Program arguments: /home/mascholz/Software/llvm/build-
release/Release+Asserts/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-
obj -mrelax-all -disable-free -main-file-name segfault_reproduction.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 -target-linker-version 2.23.2 -dwarf-column-info -resource-dir
/home/mascholz/Software/llvm/build-
release/Release+Asserts/bin/../lib/clang/3.6.0 -internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3 -internal-
isystem /usr/lib/gcc/x86_64-redhat-
linux/4.8.3/../../../../include/c++/4.8.3/x86_64-redhat-linux -internal-isystem
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3/backward -
internal-isystem /usr/local/include -internal-isystem
/home/mascholz/Software/llvm/build-
release/Release+Asserts/bin/../lib/clang/3.6.0/include -internal-externc-
isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -
fdebug-compilation-dir /home/mascholz/projekte/playground/TestClang -ferror-
limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -
fexceptions -fdiagnostics-show-option -o /tmp/mascholz/segfault_reproduction-
59c00c.o -x c++ segfault_reproduction.cpp
1. <eof> parser at end of file
2. segfault_reproduction.cpp:26:5: LLVM IR generation of declaration 'main'
3. segfault_reproduction.cpp:26:5: Generating code for declaration 'main'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.6.0 (trunk 221672)
Target: x86_64-unknown-linux-gnu
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:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/mascholz/segfault_reproduction-0eb8be.cpp
clang: note: diagnostic msg: /tmp/mascholz/segfault_reproduction-0eb8be.sh
clang: note: diagnostic msg:
********************
Compilation exited abnormally with code 254 at Tue Nov 11 11:02:27
Attached segfault_reproduction-0eb8be.cpp.zip
(234555 bytes, image/zip): segfault_reproduction-0eb8be.cpp
Attached segfault_reproduction-0eb8be.sh
(660 bytes, application/x-sh): segfault_reproduction-0eb8be.sh
still exists in clang version 3.6.0 (trunk 224573)
still exists in clang version 3.7 ( trunk 245032 )
still exists in clang version 3.8 ( trunk 250153 )
_Bug 25174 has been marked as a duplicate of this bug._
Today the assertion looks like this:
$ clang -cc1 test.ii -emit-llvm-only
clang: ../tools/clang/lib/CodeGen/CodeGenFunction.h:3117: void
clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList &,
const T *, llvm::iterator_range<CallExpr::const_arg_iterator>, const
clang::FunctionDecl *, unsigned int) [T = clang::FunctionProtoType]: Assertion
`(isGenericMethod || ((*I)->isVariablyModifiedType() ||
(*I).getNonReferenceType()->isObjCRetainableType() || getContext()
.getCanonicalType((*I).getNonReferenceType()) .getTypePtr() == getContext()
.getCanonicalType((*Arg)->getType()) .getTypePtr())) && "type mismatch in call
argument!"' failed.
And here's a standalone, no-header reduction:
template <typename unitenum, unitenum DefaultUnit> class A {
public:
template <typename settype> void set(settype, unitenum = DefaultUnit);
};
enum eDerivedUnit { UnitA };
template <>
template <typename settype>
void A<eDerivedUnit, UnitA>::set(settype, eDerivedUnit);
int main() {
A<eDerivedUnit, UnitA> a;
a.set(1);
}
This is one of those situations where a dependent type has leaked through to codegen. By providing the partial template specialization, we've bypassed the normal template instantiation logic on DefaultArgExprs.
still exists in clang version 3.8 ( trunk 256553 )
still exists in clang version 3.9 ( trunk 267385 )
Attached 2016-04-26_segfault_reproduction.txt
(8944 bytes, text/plain): Updated compiler output
Attempting to retitle to something more informative. The issue is that the dependent default argument value is slipping through without being instantiated.
segfault_reproduction.cpp
(575 bytes, text/x-c++src)segfault_reproduction-0eb8be.cpp.zip
(234555 bytes, image/zip)segfault_reproduction-0eb8be.sh
(660 bytes, application/x-sh)2016-04-26_segfault_reproduction.txt
(8944 bytes, text/plain)