[llvm-bugs] [Bug 37968] New: Modules crash-on-invalid due to struct declaration in one module, struct definition in another, but no direct dependency between the two
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 27 11:09:46 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37968
Bug ID: 37968
Summary: Modules crash-on-invalid due to struct declaration in
one module, struct definition in another, but no
direct dependency between the two
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Modules
Assignee: unassignedclangbugs at nondot.org
Reporter: dblaikie at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
This one is a bit involved to reproduce - at least I haven't been able to get
it down below 3 module interface units and a module implementation unit as
follows:
a.cppm:
export module a;
export struct a {
virtual ~a();
};
b.cppm:
export module b;
import a;
export struct b : a {
};
x.cppm:
export module x;
struct a;
export struct x {
a *m;
x();
}
x.cpp:
module x;
import b;
import a; // Buggily required import, likely (will be filed separately)
y::y() { new b(); }
compiled as:
$ clang++ -fmodules-ts -c -std=c++17 -Xclang -fmodules-codegen --precompile
a.cppm
$ clang++ -fmodules-ts -c -std=c++17 -Xclang -fmodules-codegen --precompile
b.cppm -fmodule-file=a.pcm
$ clang++ -fmodules-ts -c -std=c++17 -Xclang -fmodules-codegen --precompile
FruitBowl.cppm -fmodule-file=x.pcm
clang++-tot -fmodules-ts -c -std=c++17 x.cpp -fmodule-file=a.pcm
-fmodule-file=b.pcm -fmodule-file=x.pcm
The crash trace is as follows (apologies for any bad line wrapping):
clang-5.0:
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/AST/Decl.cpp:1422:
clang::LinkageInfo clang::LinkageComputer::getLVFo
rDecl(const clang::NamedDecl *, clang::LVComputationKind): Assertion
`D->getCachedLinkage() == LV.getLinkage()' failed.
Stack dump:
0. Program arguments:
/usr/local/google/home/blaikie/dev/llvm/build/default/bin/clang-5.0 -cc1
-triple x86_64-unknown-linux-gnu -emit-o
bj -mrelax-all -disable-free -main-file-name FruitBowl.cpp -mrelocation-model
static -mthread-model posix -mdisable-fp-elim -fmath-errno -ma
sm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu
x86-64 -dwarf-column-info -debugger-tuning=gdb -coverage-notes
-file
/usr/local/google/home/blaikie/dev/scratch/modules_cached_linkage_crash/FruitBowl.gcno
-resource-dir /usr/local/google/home/blaikie/de
v/llvm/build/default/lib/clang/7.0.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0
-internal-isystem /
usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0
-internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../.
./../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -int
ernal-isystem /usr/local/include -internal-isystem
/usr/local/google/home/blaikie/dev/llvm/build/default/lib/clang/7.0.0/include
-internal-e
xternc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++17 -fdeprecat
ed-macro -fdebug-compilation-dir
/usr/local/google/home/blaikie/dev/scratch/modules_cached_linkage_crash
-ferror-limit 19 -fmessage-length 1
40 -fmodules-ts -fno-implicit-modules -fmodule-file=AbstractFruit.pcm
-fmodule-file=Apple.pcm -fmodule-file=FruitBowl.pcm -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
FruitBowl.o -x c++ FruitBowl.cpp
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3.
/usr/local/google/home/blaikie/dev/scratch/modules_cached_linkage_crash/Apple.cppm:3:15:
Generating code for declaration 'b::~b'
#0 0x0000000006ddf5a9 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/usr/local/google/home/blaikie/dev/llvm/src/lib/Support/Unix/Signals.in
c:490:11
#1 0x0000000006ddf759 PrintStackTraceSignalHandler(void*)
/usr/local/google/home/blaikie/dev/llvm/src/lib/Support/Unix/Signals.inc:554:1
#2 0x0000000006ddda46 llvm::sys::RunSignalHandlers()
/usr/local/google/home/blaikie/dev/llvm/src/lib/Support/Signals.cpp:66:5
#3 0x0000000006ddfd87 SignalHandler(int)
/usr/local/google/home/blaikie/dev/llvm/src/lib/Support/Unix/Signals.inc:353:1
#4 0x00007f2b1af8e0c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
#5 0x00007f2b19b21fcf gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)
#6 0x00007f2b19b233fa abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)
#7 0x00007f2b19b1ae37 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)
#8 0x00007f2b19b1aee2 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)
#9 0x000000000a920ff9 clang::LinkageComputer::getLVForDecl(clang::NamedDecl
const*, clang::LVComputationKind) /usr/local/google/home/blaikie
/dev/llvm/src/tools/clang/lib/AST/Decl.cpp:1422:5
#10 0x000000000a922593
clang::LinkageComputer::getDeclLinkageAndVisibility(clang::NamedDecl const*)
/usr/local/google/home/blaikie/dev/llvm/
src/tools/clang/lib/AST/Decl.cpp:1455:10
#11 0x000000000a923f5b clang::NamedDecl::getLinkageAndVisibility() const
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/AST/Dec
l.cpp:1071:28
#12 0x00000000072da959 setLinkageForGV(llvm::GlobalValue*, clang::NamedDecl
const*) /usr/local/google/home/blaikie/dev/llvm/src/tools/clang/
lib/CodeGen/CodeGenModule.cpp:1413:24
#13 0x00000000072da622
clang::CodeGen::CodeGenModule::SetFunctionAttributes(clang::GlobalDecl,
llvm::Function*, bool, bool) /usr/local/googl
e/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:1487:19
#14 0x00000000072deba1
clang::CodeGen::CodeGenModule::GetOrCreateLLVMFunction(llvm::StringRef,
llvm::Type*, clang::GlobalDecl, bool, bool, b
ool, llvm::AttributeList, clang::CodeGen::ForDefinition_t)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenModule
.cpp:2555:18
#15 0x0000000007485ded
clang::CodeGen::CodeGenModule::getAddrOfCXXStructor(clang::CXXMethodDecl
const*, clang::CodeGen::StructorType, clang:
:CodeGen::CGFunctionInfo const*, llvm::FunctionType*, bool,
clang::CodeGen::ForDefinition_t)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGCXX.cpp:253:3
#16 0x00000000076fbbb8 (anonymous
namespace)::ItaniumCXXABI::EmitDestructorCall(clang::CodeGen::CodeGenFunction&,
clang::CXXDestructorDecl const*, clang::CXXDtorType, bool, bool,
clang::CodeGen::Address)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp:1567:27
#17 0x000000000746e1cd
clang::CodeGen::CodeGenFunction::EmitCXXDestructorCall(clang::CXXDestructorDecl
const*, clang::CXXDtorType, bool, bool, clang::CodeGen::Address)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGClass.cpp:2371:1
#18 0x000000000747b96f (anonymous
namespace)::CallBaseDtor::Emit(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::EHScopeStack::Cleanup::Flags)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGClass.cpp:499:5
#19 0x000000000742a7c9 EmitCleanup(clang::CodeGen::CodeGenFunction&,
clang::CodeGen::EHScopeStack::Cleanup*,
clang::CodeGen::EHScopeStack::Cleanup::Flags, clang::CodeGen::Address)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGCleanup.cpp:569:3
#20 0x0000000007428f5d clang::CodeGen::CodeGenFunction::PopCleanupBlock(bool)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGCleanup.cpp:775:5
#21 0x00000000074284a3
clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator,
std::initializer_list<llvm::Value**>)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGCleanup.cpp:426:3
#22 0x0000000007429fce
clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator,
unsigned long, std::initializer_list<llvm::Value**>)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGCleanup.cpp:482:19
#23 0x000000000741fb4e
clang::CodeGen::CodeGenFunction::RunCleanupsScope::ForceCleanup(std::initializer_list<llvm::Value**>)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenFunction.h:639:22
#24 0x000000000746d8dc
clang::CodeGen::CodeGenFunction::EmitDestructorBody(clang::CodeGen::FunctionArgList&)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGClass.cpp:1508:7
#25 0x000000000744e4ff
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenFunction.cpp:1341:5
#26 0x0000000007485b05
clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::CXXMethodDecl const*,
clang::CodeGen::StructorType)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CGCXX.cpp:225:3
#27 0x00000000076ff69c (anonymous
namespace)::ItaniumCXXABI::emitCXXStructor(clang::CXXMethodDecl const*,
clang::CodeGen::StructorType)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp:3842:19
#28 0x00000000072dbd67
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:2335:9
#29 0x00000000072d2d5e clang::CodeGen::CodeGenModule::EmitDeferred()
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:1761:10
#30 0x00000000072d2da0 clang::CodeGen::CodeGenModule::EmitDeferred()
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:1763:7
#31 0x00000000072d2da0 clang::CodeGen::CodeGenModule::EmitDeferred()
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:1763:7
#32 0x00000000072d2da0 clang::CodeGen::CodeGenModule::EmitDeferred()
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:1763:7
#33 0x00000000072d13c5 clang::CodeGen::CodeGenModule::Release()
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:393:3
#34 0x0000000007cbcdc2 (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/ModuleBuilder.cpp:269:11
#35 0x0000000007cb7b1e
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenAction.cpp:236:14
#36 0x000000000953b1c9 clang::ParseAST(clang::Sema&, bool, bool)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/Parse/ParseAST.cpp:171:12
#37 0x0000000007b0b042 clang::ASTFrontendAction::ExecuteAction()
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/Frontend/FrontendAction.cpp:1013:1
#38 0x0000000007cb5652 clang::CodeGenAction::ExecuteAction()
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/CodeGen/CodeGenAction.cpp:1044:1
#39 0x0000000007b0aa80 clang::FrontendAction::Execute()
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/Frontend/FrontendAction.cpp:914:7
#40 0x00000000079de339
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/Frontend/CompilerInstance.cpp:990:7
#41 0x0000000007c9fc3f
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:257:8
#42 0x00000000043b4196 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/driver/cc1_main.cpp:222:11
#43 0x00000000043a7462 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef)
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/driver/driver.cpp:310:5
#44 0x00000000043a6094 main
/usr/local/google/home/blaikie/dev/llvm/src/tools/clang/tools/driver/driver.cpp:382:5
#45 0x00007f2b19b0f2b1 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x202b1)
#46 0x00000000043a502a _start
(/usr/local/google/home/blaikie/dev/llvm/build/default/bin/clang-5.0+0x43a502a)
--
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/20180627/935e44ad/attachment-0001.html>
More information about the llvm-bugs
mailing list