-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang][ASTWriter] Assertion `(Value < (1u << BitsWidth)) && "Passing narrower bit width!"' failed. #76443
Comments
@llvm/issue-subscribers-clang-frontend Author: widberg (widberg)
When trying to compile a PCH using the following command on trunk (d51e06c)
test.sh clang++-18 -cc1 -std=c++17 -emit-pch -o qstyle.cpp.oclango qstyle.cpp qstyle.cpp (reduced from qtbase via cvise) template <int... Nx> int stringData(const char (&...x)[Nx]) {
return 0;
}
int qt_meta_stringdata_CLASSQStyleENDCLASS = stringData(
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", ""); The command crashes with this backtrace clang++-18: /data/llvm-project/clang/include/clang/Serialization/ASTWriter.h:901: void clang::BitsPacker::addBits(uint32_t, uint32_t): Assertion `(Value < (1u << BitsWidth)) && "Passing narrower bit width!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clang++-18 -cc1 -std=c++17 -emit-pch -ferror-limit 0 -o qstyle.cpp.oclango qstyle.cpp
1. <eof> parser at end of file
2. qstyle.cpp:1:53: serializing 'x'
#<!-- -->0 0x000055555add97b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /data/llvm-project/llvm/lib/Support/Unix/Signals.inc:727:0
#<!-- -->1 0x000055555add72f4 llvm::sys::RunSignalHandlers() /data/llvm-project/llvm/lib/Support/Signals.cpp:105:0
#<!-- -->2 0x000055555add7f0e SignalHandler(int) /data/llvm-project/llvm/lib/Support/Unix/Signals.inc:403:0
#<!-- -->3 0x00007ffff7bc6980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#<!-- -->4 0x00007ffff67f4e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#<!-- -->5 0x00007ffff67f67f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
#<!-- -->6 0x00007ffff67e63fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
#<!-- -->7 0x00007ffff67e6472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#<!-- -->8 0x000055555bc09ba9 (/data/llvm-project/build/bin/clang-18+0x66b5ba9)
#<!-- -->9 0x000055555bc51169 clang::ParmVarDecl::getObjCDeclQualifier() const /data/llvm-project/clang/include/clang/AST/Decl.h:1813:0
#<!-- -->10 0x000055555bc51169 clang::ASTDeclWriter::VisitParmVarDecl(clang::ParmVarDecl*) /data/llvm-project/clang/lib/Serialization/ASTWriterDecl.cpp:1171:0
#<!-- -->11 0x000055555bc551cf decltype(auto) llvm::dyn_cast<clang::DeclaratorDecl, clang::Decl>(clang::Decl*) /data/llvm-project/llvm/include/llvm/Support/Casting.h:662:0
#<!-- -->12 0x000055555bc551cf clang::ASTDeclWriter::Visit(clang::Decl*) /data/llvm-project/clang/lib/Serialization/ASTWriterDecl.cpp:279:0
#<!-- -->13 0x000055555bc55523 clang::ASTDeclWriter::Emit(clang::Decl*) /data/llvm-project/clang/lib/Serialization/ASTWriterDecl.cpp:50:0
#<!-- -->14 0x000055555bc55523 clang::ASTWriter::WriteDecl(clang::ASTContext&, clang::Decl*) /data/llvm-project/clang/lib/Serialization/ASTWriterDecl.cpp:2723:0
#<!-- -->15 0x000055555bc45510 clang::ASTWriter::WriteASTCore(clang::Sema&, llvm::StringRef, clang::Module*) /data/llvm-project/clang/lib/Serialization/ASTWriter.cpp:5089:0
#<!-- -->16 0x000055555bc46865 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::_M_set_length(unsigned long) /usr/include/c++/7/bits/basic_string.h:206:0
#<!-- -->17 0x000055555bc46865 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::clear() /usr/include/c++/7/bits/basic_string.h:1014:0
#<!-- -->18 0x000055555bc46865 clang::ASTWriter::WriteAST(clang::Sema&, llvm::StringRef, clang::Module*, llvm::StringRef, bool) /data/llvm-project/clang/lib/Serialization/ASTWriter.cpp:4643:0
#<!-- -->19 0x000055555bc64220 std::__shared_ptr_access<clang::PCHBuffer, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get() const /usr/include/c++/7/bits/shared_ptr_base.h:975:0
#<!-- -->20 0x000055555bc64220 std::__shared_ptr_access<clang::PCHBuffer, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const /usr/include/c++/7/bits/shared_ptr_base.h:969:0
#<!-- -->21 0x000055555bc64220 clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&) /data/llvm-project/clang/lib/Serialization/GeneratePCH.cpp:68:0
#<!-- -->22 0x000055555bad7c08 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) /data/llvm-project/clang/lib/Frontend/MultiplexConsumer.cpp:297:0
#<!-- -->23 0x000055555cd42589 clang::ParseAST(clang::Sema&, bool, bool) /data/llvm-project/clang/lib/Parse/ParseAST.cpp:176:0
#<!-- -->24 0x000055555baa5379 clang::FrontendAction::Execute() /data/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1069:0
#<!-- -->25 0x000055555ba30e50 llvm::Error::setChecked(bool) /data/llvm-project/llvm/include/llvm/Support/Error.h:307:0
#<!-- -->26 0x000055555ba30e50 llvm::Error::operator bool() /data/llvm-project/llvm/include/llvm/Support/Error.h:239:0
#<!-- -->27 0x000055555ba30e50 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /data/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1057:0
#<!-- -->28 0x000055555bb361f3 std::__shared_ptr_access<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2, false, false>::_M_get() const /usr/include/c++/7/bits/shared_ptr_base.h:975:0
#<!-- -->29 0x000055555bb361f3 std::__shared_ptr_access<clang::FrontendOptions, (__gnu_cxx::_Lock_policy)2, false, false>::operator*() const /usr/include/c++/7/bits/shared_ptr_base.h:961:0
#<!-- -->30 0x000055555bb361f3 clang::CompilerInvocation::getFrontendOpts() /data/llvm-project/clang/include/clang/Frontend/CompilerInvocation.h:254:0
#<!-- -->31 0x000055555bb361f3 clang::CompilerInstance::getFrontendOpts() /data/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:291:0
#<!-- -->32 0x000055555bb361f3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /data/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:273:0
#<!-- -->33 0x000055555954097e cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /data/llvm-project/clang/tools/driver/cc1_main.cpp:294:0
#<!-- -->34 0x0000555559537c38 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) /data/llvm-project/clang/tools/driver/driver.cpp:366:0
#<!-- -->35 0x000055555953b0a4 clang_main(int, char**, llvm::ToolContext const&) /data/llvm-project/clang/tools/driver/driver.cpp:407:0
#<!-- -->36 0x000055555954c9e1 main /data/llvm-project/build/tools/clang/tools/driver/clang-driver.cpp:16:0
#<!-- -->37 0x00007ffff67d7c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#<!-- -->38 0x0000555559536f6a _start (/data/llvm-project/build/bin/clang-18+0x3fe2f6a)
./test.sh: line 1: 29285 Aborted (core dumped) clang++-18 -cc1 -std=c++17 -emit-pch -ferror-limit 0 -o qstyle.cpp.oclango qstyle.cpp |
CC @ChuanqiXu9 It looks like you added this assert in 48be81e When debugging this I see: frame var Value
(uint32_t) Value = 256
frame var BitsWidth
(uint32_t) BitsWidth = 8
expr 1u << 8
(unsigned int) $0 = 256 So your assuming that llvm-project/clang/include/clang/AST/Decl.h Lines 1928 to 1931 in fdb8764
we can see that if |
Oh, my bad. My motivation was that I see the size of ParameterIndex is limited to 8: llvm-project/clang/include/clang/AST/Decl.h Lines 989 to 1035 in fdb8764
I didn't notice there is |
When trying to compile a PCH using the following command on trunk (d51e06c)
test.sh
qstyle.cpp (reduced from qtbase via cvise)
The command crashes with this backtrace
The text was updated successfully, but these errors were encountered: