Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

crash in mangler when using a declaration from an imported c++20 module #41658

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR42688
Status NEW
Importance P enhancement
Reported by Mathias Stearn (redbeard0531@gmail.com)
Reported on 2019-07-19 06:09:16 -0700
Last modified on 2019-07-19 06:19:21 -0700
Version trunk
Hardware PC Windows NT
CC blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments query_builder-384681.cpp (40593 bytes, text/plain)
query_builder-384681.sh (29275 bytes, text/plain)
src_realm_parser_query_builder.cpp.ii.xz (671544 bytes, application/x-xz)
Blocks
Blocked by
See also
Created attachment 22262
query_builder.cpp

With clang build from git trunk about an hour ago. Since this is using modules,
I'm also uploading the output of -E -frewrite-imports.

clang-9: /home/mstearn/opensource/llvm-project/clang/lib/AST/Decl.cpp:1491:
clang::LinkageInfo clang::LinkageComputer::getLVForDecl(const clang::NamedDecl
*, clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage() == D-
>getCachedLinkage()' failed.
Stack dump:
0.      Program arguments: /home/mstearn/opensource/llvm-
project/build/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -
mrelax-all -disable-free -main-file-name query_builder.cpp -mrelocation-model
pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-
verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-
64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-
tuning=gdb -ggnu-pubnames -split-dwarf-file
build_mod/src_realm_parser_query_builder.cpp.dwo -split-dwarf-output
build_mod/src_realm_parser_query_builder.cpp.dwo -coverage-notes-file
/home/mstearn/realm-core/build_mod/src_realm_parser_query_builder.cpp.gcno -
resource-dir /home/mstearn/opensource/llvm-project/build/lib/clang/10.0.0 -
dependency-file build_mod/src_realm_parser_query_builder.cpp.o.d -MT
build_mod/src_realm_parser_query_builder.cpp.o -sys-header-deps -I src -I
build/src -I src/external/pegtl/include/tao/ -D REALM_DEBUG=1 -internal-isystem
/usr/include/c++/v1 -internal-isystem /usr/local/include -internal-isystem
/home/mstearn/opensource/llvm-project/build/lib/clang/10.0.0/include -internal-
externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-
command-line-argument -std=c++2a -fdeprecated-macro -fdebug-compilation-dir
/home/mstearn/realm-core -ferror-limit 19 -fmessage-length 0 -pthread -fno-
implicit-modules -fmodule-file=build_mod/_usr_include_c++_v1_algorithm.pcm -
fmodule-file=build_mod/_usr_include_c++_v1_array.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_atomic.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cctype.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cerrno.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cfloat.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_chrono.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_climits.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cmath.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cstdarg.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cstdint.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cstdio.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cstdlib.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cstring.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_ctime.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_cwchar.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_exception.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_functional.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_initializer_list.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_iomanip.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_iosfwd.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_iostream.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_istream.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_iterator.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_limits.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_locale.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_map.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_memory.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_mutex.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_new.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_numeric.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_optional.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_ostream.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_sstream.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_stdexcept.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_streambuf.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_string.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_string_view.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_system_error.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_tuple.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_type_traits.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_typeinfo.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_unordered_map.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_unordered_set.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_utility.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_vector.pcm -fmodule-
file=build_mod/_usr_include_c++_v1_version.pcm -fmodule-
file=build_mod/mod_links/realm_parser_expression_container.pcm -fmodule-
file=build_mod/src_realm_alloc.hpp.pcm -fmodule-
file=build_mod/src_realm_alloc_slab.hpp.pcm -fmodule-
file=build_mod/src_realm_array.hpp.pcm -fmodule-
file=build_mod/src_realm_array_basic.hpp.pcm -fmodule-
file=build_mod/src_realm_array_binary.hpp.pcm -fmodule-
file=build_mod/src_realm_array_blob.hpp.pcm -fmodule-
file=build_mod/src_realm_array_blobs_big.hpp.pcm -fmodule-
file=build_mod/src_realm_array_direct.hpp.pcm -fmodule-
file=build_mod/src_realm_array_integer.hpp.pcm -fmodule-
file=build_mod/src_realm_array_string.hpp.pcm -fmodule-
file=build_mod/src_realm_array_string_long.hpp.pcm -fmodule-
file=build_mod/src_realm_binary_data.hpp.pcm -fmodule-
file=build_mod/src_realm_bptree.hpp.pcm -fmodule-
file=build_mod/src_realm_column.hpp.pcm -fmodule-
file=build_mod/src_realm_column_backlink.hpp.pcm -fmodule-
file=build_mod/src_realm_column_binary.hpp.pcm -fmodule-
file=build_mod/src_realm_column_fwd.hpp.pcm -fmodule-
file=build_mod/src_realm_column_link.hpp.pcm -fmodule-
file=build_mod/src_realm_column_linkbase.hpp.pcm -fmodule-
file=build_mod/src_realm_column_linklist.hpp.pcm -fmodule-
file=build_mod/src_realm_column_mixed.hpp.pcm -fmodule-
file=build_mod/src_realm_column_string.hpp.pcm -fmodule-
file=build_mod/src_realm_column_string_enum.hpp.pcm -fmodule-
file=build_mod/src_realm_column_table.hpp.pcm -fmodule-
file=build_mod/src_realm_column_timestamp.hpp.pcm -fmodule-
file=build_mod/src_realm_column_type.hpp.pcm -fmodule-
file=build_mod/src_realm_column_type_traits.hpp.pcm -fmodule-
file=build_mod/src_realm_data_type.hpp.pcm -fmodule-
file=build_mod/src_realm_descriptor.hpp.pcm -fmodule-
file=build_mod/src_realm_descriptor_fwd.hpp.pcm -fmodule-
file=build_mod/src_realm_disable_sync_to_disk.hpp.pcm -fmodule-
file=build_mod/src_realm_exceptions.hpp.pcm -fmodule-
file=build_mod/src_realm_group.hpp.pcm -fmodule-
file=build_mod/src_realm_group_shared.hpp.pcm -fmodule-
file=build_mod/src_realm_group_shared_options.hpp.pcm -fmodule-
file=build_mod/src_realm_handover_defs.hpp.pcm -fmodule-
file=build_mod/src_realm_impl_array_writer.hpp.pcm -fmodule-
file=build_mod/src_realm_impl_cont_transact_hist.hpp.pcm -fmodule-
file=build_mod/src_realm_impl_destroy_guard.hpp.pcm -fmodule-
file=build_mod/src_realm_impl_input_stream.hpp.pcm -fmodule-
file=build_mod/src_realm_impl_output_stream.hpp.pcm -fmodule-
file=build_mod/src_realm_impl_sequential_getter.hpp.pcm -fmodule-
file=build_mod/src_realm_impl_transact_log.hpp.pcm -fmodule-
file=build_mod/src_realm_index_string.hpp.pcm -fmodule-
file=build_mod/src_realm_link_view.hpp.pcm -fmodule-
file=build_mod/src_realm_link_view_fwd.hpp.pcm -fmodule-
file=build_mod/src_realm_metrics_metric_timer.hpp.pcm -fmodule-
file=build_mod/src_realm_metrics_metrics.hpp.pcm -fmodule-
file=build_mod/src_realm_metrics_query_info.hpp.pcm -fmodule-
file=build_mod/src_realm_metrics_transaction_info.hpp.pcm -fmodule-
file=build_mod/src_realm_mixed.hpp.pcm -fmodule-
file=build_mod/src_realm_null.hpp.pcm -fmodule-
file=build_mod/src_realm_olddatetime.hpp.pcm -fmodule-
file=build_mod/src_realm_owned_data.hpp.pcm -fmodule-
file=build_mod/src_realm_parser_keypath_mapping.hpp.pcm -fmodule-
file=build_mod/src_realm_parser_parser.hpp.pcm -fmodule-
file=build_mod/src_realm_parser_parser_utils.hpp.pcm -fmodule-
file=build_mod/src_realm_parser_query_builder.hpp.pcm -fmodule-
file=build_mod/src_realm_query.hpp.pcm -fmodule-
file=build_mod/src_realm_query_conditions.hpp.pcm -fmodule-
file=build_mod/src_realm_query_engine.hpp.pcm -fmodule-
file=build_mod/src_realm_query_expression.hpp.pcm -fmodule-
file=build_mod/src_realm_query_operators.hpp.pcm -fmodule-
file=build_mod/src_realm_replication.hpp.pcm -fmodule-
file=build_mod/src_realm_row.hpp.pcm -fmodule-
file=build_mod/src_realm_spec.hpp.pcm -fmodule-
file=build_mod/src_realm_string_data.hpp.pcm -fmodule-
file=build_mod/src_realm_table.hpp.pcm -fmodule-
file=build_mod/src_realm_table_ref.hpp.pcm -fmodule-
file=build_mod/src_realm_table_view.hpp.pcm -fmodule-
file=build_mod/src_realm_timestamp.hpp.pcm -fmodule-
file=build_mod/src_realm_unicode.hpp.pcm -fmodule-
file=build_mod/src_realm_util_allocator.hpp.pcm -fmodule-
file=build_mod/src_realm_util_any.hpp.pcm -fmodule-
file=build_mod/src_realm_util_assert.hpp.pcm -fmodule-
file=build_mod/src_realm_util_backtrace.hpp.pcm -fmodule-
file=build_mod/src_realm_util_bind_ptr.hpp.pcm -fmodule-
file=build_mod/src_realm_util_buffer.hpp.pcm -fmodule-
file=build_mod/src_realm_util_encrypted_file_mapping.hpp.pcm -fmodule-
file=build_mod/src_realm_util_features.h.pcm -fmodule-
file=build_mod/src_realm_util_file.hpp.pcm -fmodule-
file=build_mod/src_realm_util_file_mapper.hpp.pcm -fmodule-
file=build_mod/src_realm_util_fixed_size_buffer.hpp.pcm -fmodule-
file=build_mod/src_realm_util_interprocess_condvar.hpp.pcm -fmodule-
file=build_mod/src_realm_util_interprocess_mutex.hpp.pcm -fmodule-
file=build_mod/src_realm_util_miscellaneous.hpp.pcm -fmodule-
file=build_mod/src_realm_util_optional.hpp.pcm -fmodule-
file=build_mod/src_realm_util_safe_int_ops.hpp.pcm -fmodule-
file=build_mod/src_realm_util_serializer.hpp.pcm -fmodule-
file=build_mod/src_realm_util_shared_ptr.hpp.pcm -fmodule-
file=build_mod/src_realm_util_string_buffer.hpp.pcm -fmodule-
file=build_mod/src_realm_util_terminate.hpp.pcm -fmodule-
file=build_mod/src_realm_util_thread.hpp.pcm -fmodule-
file=build_mod/src_realm_util_to_string.hpp.pcm -fmodule-
file=build_mod/src_realm_util_type_list.hpp.pcm -fmodule-
file=build_mod/src_realm_util_type_traits.hpp.pcm -fmodule-
file=build_mod/src_realm_utilities.hpp.pcm -fmodule-
file=build_mod/src_realm_version.hpp.pcm -fmodule-
file=build_mod/src_realm_version_id.hpp.pcm -fmodule-
file=build_mod/src_realm_views.hpp.pcm -fobjc-runtime=gcc -fcxx-exceptions -
fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig -o
build_mod/src_realm_parser_query_builder.cpp.o -x c++
src/realm/parser/query_builder.cpp
1.      src/realm/parser/query_builder.cpp:757:1: current parser token
'namespace'
2.      LLVM IR generation of declaration '<using-directive>'
3.      src/realm/parser/query_builder.cpp:510:6: Mangling declaration
'(anonymous namespace)::add_comparison_to_query'
 #0 0x000055c0542c4c42 PrintStackTraceSignalHandler(void*) (/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4c67c42)
 #1 0x000055c0542c257e llvm::sys::RunSignalHandlers() (/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4c6557e)
 #2 0x000055c0542c50f1 SignalHandler(int) (/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4c680f1)
 #3 0x00007f4a0ca35d00 __restore_rt (/usr/lib/libpthread.so.0+0x13d00)
 #4 0x00007f4a0c3a3755 raise (/usr/lib/libc.so.6+0x3a755)
 #5 0x00007f4a0c38e851 abort (/usr/lib/libc.so.6+0x25851)
 #6 0x00007f4a0c38e727 _nl_load_domain.cold (/usr/lib/libc.so.6+0x25727)
 #7 0x00007f4a0c39c026 (/usr/lib/libc.so.6+0x33026)
 #8 0x000055c056439d46 clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*, clang::LVComputationKind) (/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ddcd46)
 #9 0x000055c05643c8ff clang::NamedDecl::getLinkageInternal() const (/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ddf8ff)
#10 0x000055c05654dd94 (anonymous
namespace)::CXXNameMangler::mangleUnqualifiedName(clang::NamedDecl const*,
clang::DeclarationName, unsigned int, llvm::SmallVector<llvm::StringRef, 4u>
const*) (/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ef0d94)
#11 0x000055c05654fbb6 (anonymous
namespace)::CXXNameMangler::manglePrefix(clang::DeclContext const*, bool)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ef2bb6)
#12 0x000055c0565510ce (anonymous
namespace)::CXXNameMangler::mangleNestedName(clang::NamedDecl const*,
clang::DeclContext const*, llvm::SmallVector<llvm::StringRef, 4u> const*, bool)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ef40ce)
#13 0x000055c05653ddd6 (anonymous
namespace)::CXXNameMangler::mangleName(clang::NamedDecl const*)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ee0dd6)
#14 0x000055c05653f548 (anonymous
namespace)::CXXNameMangler::mangleType(clang::QualType)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ee2548)
#15 0x000055c056540973 (anonymous
namespace)::CXXNameMangler::mangleType(clang::QualType)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ee3973)
#16 0x000055c05654d281 (anonymous
namespace)::CXXNameMangler::mangleBareFunctionType(clang::FunctionProtoType
const*, bool, clang::FunctionDecl const*) (/home/mstearn/opensource/llvm-
project/build/bin/clang-9+0x6ef0281)
#17 0x000055c05653d2de (anonymous
namespace)::CXXNameMangler::mangleFunctionEncoding(clang::FunctionDecl const*)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6ee02de)
#18 0x000055c05653af18 (anonymous
namespace)::ItaniumMangleContextImpl::mangleCXXName(clang::NamedDecl const*,
llvm::raw_ostream&) (/home/mstearn/opensource/llvm-project/build/bin/clang-
9+0x6eddf18)
#19 0x000055c0545a127d getMangledNameImpl(clang::CodeGen::CodeGenModule const&,
clang::GlobalDecl, clang::NamedDecl const*, bool)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4f4427d)
#20 0x000055c05459c075
clang::CodeGen::CodeGenModule::getMangledName(clang::GlobalDecl)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4f3f075)
#21 0x000055c0545adab0
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4f50ab0)
#22 0x000055c0545b4374
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4f57374)
#23 0x000055c0545b853b
clang::CodeGen::CodeGenModule::EmitDeclContext(clang::DeclContext const*)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4f5b53b)
#24 0x000055c0545b4911
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x4f57911)
#25 0x000055c054b6d270 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x5510270)
#26 0x000055c054b6a65c
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x550d65c)
#27 0x000055c055961473 clang::ParseAST(clang::Sema&, bool, bool)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x6304473)
#28 0x000055c054b695fb clang::CodeGenAction::ExecuteAction()
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x550c5fb)
#29 0x000055c054ac08fe clang::FrontendAction::Execute()
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x54638fe)
#30 0x000055c054a239d8
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x53c69d8)
#31 0x000055c054b6465e
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x550765e)
#32 0x000055c052614adb cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/mstearn/opensource/llvm-project/build/bin/clang-9+0x2fb7adb)
#33 0x000055c0526103ca main (/home/mstearn/opensource/llvm-
project/build/bin/clang-9+0x2fb33ca)
#34 0x00007f4a0c38fee3 __libc_start_main (/usr/lib/libc.so.6+0x26ee3)
#35 0x000055c05260d02e _start (/home/mstearn/opensource/llvm-
project/build/bin/clang-9+0x2fb002e)
clang-9: error: unable to execute command: Aborted
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0 (https://github.com/llvm/llvm-project.git
20a0e7caaf39d14929c1469f341acb664356eeb9)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/mstearn/opensource/llvm-project/build/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-9: note: diagnostic msg:
********************

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

********************
Quuxplusone commented 5 years ago

Attached query_builder-384681.sh (29275 bytes, text/plain): query_builder.sh

Quuxplusone commented 5 years ago

Attached query_builder-384681.cpp (40593 bytes, text/plain): query_builder.cpp

Quuxplusone commented 5 years ago

Attached src_realm_parser_query_builder.cpp.ii.xz (671544 bytes, application/x-xz): query_builder.ii.xz (-frewrite-imports)