llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Regression(r326602): Assertion failed: (Idx >= 1 && "stored index must be base-1"), function getLLVMIndex, file /b/build/slave/clang-tot-device/build/src/third_party/llvm/tools/clang/include/clang/AST/Attr.h, line 282.

Open nico opened this issue 8 years ago • 12 comments

Bugzilla Link 36620
Resolution FIXED
Resolved on Mar 13, 2018 08:08
Version unspecified
OS Linux
CC @jdenny-ornl

Extended Description

We're getting this on our chromium ios trunk bot. Stack:

Assertion failed: (Idx >= 1 && "stored index must be base-1"), function getLLVMIndex, file /b/build/slave/clang-tot-device/build/src/third_party/llvm/tools/clang/include/clang/AST/Attr.h, line 282. 0 clang++ 0x000000010fb8e5b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40 1 clang++ 0x000000010fb8ec76 SignalHandler(int) + 470 2 libsystem_platform.dylib 0x00007fffa2f43b3a _sigtramp + 26 3 libsystem_platform.dylib 0xff80000000001012 _sigtramp + 1561056498 4 libsystem_c.dylib 0x00007fffa2dc8420 abort + 129 5 libsystem_c.dylib 0x00007fffa2d8f893 basename_r + 0 6 clang++ 0x000000010fdee216 clang::CodeGen::CodeGenModule::ConstructAttributeList(llvm::StringRef, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::CGCalleeInfo, llvm::AttributeList&, unsigned int&, bool) + 5590 7 clang++ 0x000000010ffb1731 clang::CodeGen::CodeGenModule::SetFunctionAttributes(clang::GlobalDecl, llvm::Function*, bool, bool) + 225 8 clang++ 0x000000010ffb4494 clang::CodeGen::CodeGenModule::GetOrCreateLLVMFunction(llvm::StringRef, llvm::Type*, clang::GlobalDecl, bool, bool, bool, llvm::AttributeList, clang::CodeGen::ForDefinition_t) + 1796 9 clang++ 0x000000010ffb85df clang::CodeGen::CodeGenModule::GetAddrOfFunction(clang::GlobalDecl, llvm::Type*, bool, bool, clang::CodeGen::ForDefinition_t) + 223 10 clang++ 0x000000010fe67717 EmitFunctionDeclPointer(clang::CodeGen::CodeGenModule&, clang::FunctionDecl const*) + 103 11 clang++ 0x000000010fe60e59 EmitFunctionDeclLValue(clang::CodeGen::CodeGenFunction&, clang::Expr const*, clang::FunctionDecl const*) + 41 12 clang++ 0x000000010fe55a8c clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) + 2028 13 clang++ 0x000000010fe4bee6 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) + 838 14 clang++ 0x000000010fe9b8d8 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) + 1624 15 clang++ 0x000000010fe8bc88 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 104 16 clang++ 0x000000010fdab10f clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::FunctionDecl const*, unsigned int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) + 55135 17 clang++ 0x000000010fe647c1 clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*, clang::CodeGen::ReturnValueSlot) + 305 18 clang++ 0x000000010fe98af4 (anonymous namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*) + 180 19 clang++ 0x000000010fe9b315 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) + 149 20 clang++ 0x000000010fe8bc88 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 104 21 clang++ 0x000000010fe361ae clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) + 158 22 clang++ 0x000000010fe394aa clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) + 314 23 clang++ 0x000000010fe0197b clang::CodeGen::CodeGenFunction::EmitInitializerForField(clang::FieldDecl*, clang::CodeGen::LValue, clang::Expr*) + 315 24 clang++ 0x000000010fe0b7d2 EmitMemberInitializer(clang::CodeGen::CodeGenFunction&, clang::CXXRecordDecl const*, clang::CXXCtorInitializer*, clang::CXXConstructorDecl const*, clang::CodeGen::FunctionArgList&) + 1058 25 clang++ 0x000000010fe0311d clang::CodeGen::CodeGenFunction::EmitCtorPrologue(clang::CXXConstructorDecl const*, clang::CXXCtorType, clang::CodeGen::FunctionArgList&) + 1933 26 clang++ 0x000000010fe02475 clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) + 341 27 clang++ 0x000000010ffa0a2a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 522 28 clang++ 0x000000010fde2b37 clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::CXXMethodDecl const*, clang::CodeGen::StructorType) + 327 29 clang++ 0x0000000110021ef9 (anonymous namespace)::ItaniumCXXABI::emitCXXStructor(clang::CXXMethodDecl const*, clang::CodeGen::StructorType) + 889 30 clang++ 0x000000010ffb28d1 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 337 31 clang++ 0x000000010ffaabc5 clang::CodeGen::CodeGenModule::EmitDeferred() + 229 32 clang++ 0x000000010ffaabed clang::CodeGen::CodeGenModule::EmitDeferred() + 269 33 clang++ 0x000000010ffaabed clang::CodeGen::CodeGenModule::EmitDeferred() + 269 34 clang++ 0x000000010ffaabed clang::CodeGen::CodeGenModule::EmitDeferred() + 269 35 clang++ 0x000000010ffaabed clang::CodeGen::CodeGenModule::EmitDeferred() + 269 36 clang++ 0x000000010ffaabed clang::CodeGen::CodeGenModule::EmitDeferred() + 269 37 clang++ 0x000000010ffaabed clang::CodeGen::CodeGenModule::EmitDeferred() + 269 38 clang++ 0x000000010ffaa10a clang::CodeGen::CodeGenModule::Release() + 42 39 clang++ 0x000000011003eda4 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) + 100 40 clang++ 0x000000010ff97a27 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 119 41 clang++ 0x000000011020bc0c clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) + 44 42 clang++ 0x0000000110b8c684 clang::ParseAST(clang::Sema&, bool, bool) + 516 43 clang++ 0x00000001101e24bc clang::FrontendAction::Execute() + 76 44 clang++ 0x000000011019a9d1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1233 45 clang++ 0x000000011022f978 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1736 46 clang++ 0x000000010e2b5b0b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 1499 47 clang++ 0x000000010e2b37c7 main + 10903 48 libdyld.dylib 0x00007fffa2d34235 start + 1

Don't have a repro yet, will attach it later today hopefully.

nico avatar Mar 06 '18 21:03 nico

Fixed by r327405.

jdenny-ornl avatar Mar 13 '18 15:03 jdenny-ornl

Sounds great, thanks!

nico avatar Mar 12 '18 01:03 nico

Yep, that reproduced the failure for me. Thanks.

The patch I posted does fix this bug. I've decided I'm going to put it through another phabricator review before committing because it has changed somewhat since the previous review.

jdenny-ornl avatar Mar 12 '18 00:03 jdenny-ornl

repro, pch input Ah, I guess your stdlib.h doesn't work with the macOS's. Here's foo.h from my system as printed by -E -frewrite-includes.

With that, these commands work for me:

$ bin/clang -fno-strict-aliasing -fstack-protector -fcolor-diagnostics -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64 -fno-omit-frame-pointer -gdwarf-2 -mmacosx-version-min=10.9.0 -fvisibility=hidden -O2 -std=c++14 -stdlib=libc++ -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -x c++-header foo.h -o precompile.h-cc.gch

$ bin/clang++ -fno-strict-aliasing -fstack-protector -Wno-builtin-macro-redefined -fcolor-diagnostics -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64 -fno-omit-frame-pointer -gdwarf-2 -mmacosx-version-min=10.9.0 -fvisibility=hidden -O2 -std=c++14 -stdlib=libc++ -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -include precompile.h-cc -c foo.cc -o tmp.o

You might have to say `-target "x86_64-apple-macosx10.9.0" instead of -arch x86_64. Does that help?

nico avatar Mar 11 '18 20:03 nico

Hi Nico,

When I ran your first command from comment #​2, I saw:

clang: error: argument unused during compilation: '-arch x86_64' [-Werror,-Wunused-command-line-argument] clang: error: argument unused during compilation: '-mmacosx-version-min=10.9.0' [-Werror,-Wunused-command-line-argument]

I tried again without "-mmacosx-version-min=10.9.0" and "-arch x86_64", and it appeared to succeed.

I then tried your second command from comment #​2, and I had to remove "-arch x86_64", "-isysroot $(xcrun -show-sdk-path)", and "-mmacosx-version-min=10.9.0". Then I saw many compilation errors starting with:

In file included from ../../base/files/file_enumerator_posix.cc:5: In file included from ../../base/files/file_enumerator.h:9: In file included from ../../../../llvm-build-goma/include/c++/v1/stdint.h:119: In file included from ../../../../llvm-build-goma/lib/clang/7.0.0/include/stdint.h:63: In file included from ../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/stdint.h:21: ../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/sys/_types/_int64_t.h:30:20: error: typedef redefinition with different types ('long long' vs '__int64_t' (aka 'long')) typedef long long int64_t; ^ /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: previous definition is here typedef __int64_t int64_t;

Do you see that?

Thanks.

jdenny-ornl avatar Mar 11 '18 18:03 jdenny-ornl

The test case should be standalone and platform independent. You can probably omit most flags (I guess isysroot is the one giving you pause?)

nico avatar Mar 11 '18 13:03 nico

proposed fix for r326602 I cleaned up my previous patch a bit. They should be functionally equivalent, so it shouldn't be necessary to switch if you've already gotten started. Just let me know which one you try. Thanks.

jdenny-ornl avatar Mar 09 '18 15:03 jdenny-ornl

proposed fix for r326602 Hi Nico,

I found a serialization bug in r326602 that I think might be the culprit, but I don't know how to try your reproducer on my platform. The attached patch revises r326602 to include a fix. Would you please let me know if it fixes the bug you reported?

The change to r326602 is small but not trivial. Is it customary to reopen the original issue in phabricator and review again before committing?

Thanks.

jdenny-ornl avatar Mar 08 '18 19:03 jdenny-ornl

Reverting 326862 locally makes this assert go away. Landing revert:

$ svn merge -c -326602 . --- Reverse-merging r326602 into '.': U utils/TableGen/ClangAttrEmitter.cpp U lib/Sema/SemaChecking.cpp U lib/Sema/SemaDeclAttr.cpp U lib/Sema/SemaTemplateInstantiateDecl.cpp U lib/Sema/SemaDecl.cpp U lib/AST/ExprConstant.cpp U lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp U lib/StaticAnalyzer/Checkers/MallocChecker.cpp U lib/CodeGen/CGCall.cpp U test/Sema/error-type-safety.cpp U test/Sema/attr-print.cpp D test/Sema/attr-ownership.cpp C test/CodeGenCXX/alloc-size.cpp U test/Misc/ast-dump-attr.cpp U include/clang/Basic/Attr.td U include/clang/AST/Attr.h --- Recording mergeinfo for reverse merge of r326602 into '.': U . Summary of conflicts: Text conflicts: 1 Conflict discovered in file 'test/CodeGenCXX/alloc-size.cpp'. Select: (p) postpone, (df) show diff, (e) edit file, (m) merge, (mc) my side of conflict, (tc) their side of conflict, (s) show all options: p Summary of conflicts: Text conflicts: 1 $ mvim test/CodeGenCXX/alloc-size.cpp $ svn resolved test/CodeGenCXX/alloc-size.cpp Resolved conflicted state of 'test/CodeGenCXX/alloc-size.cpp' $ svn commit -m 'Revert r326602, it caused llvm/llvm-project#35968 .' Sending include/clang/AST/Attr.h Sending include/clang/Basic/Attr.td Sending lib/AST/ExprConstant.cpp Sending lib/CodeGen/CGCall.cpp Sending lib/Sema/SemaChecking.cpp Sending lib/Sema/SemaDecl.cpp Sending lib/Sema/SemaDeclAttr.cpp Sending lib/Sema/SemaTemplateInstantiateDecl.cpp Sending lib/StaticAnalyzer/Checkers/MallocChecker.cpp Sending lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp Sending test/CodeGenCXX/alloc-size.cpp Sending test/Misc/ast-dump-attr.cpp Deleting test/Sema/attr-ownership.cpp Sending test/Sema/attr-print.cpp Sending test/Sema/error-type-safety.cpp Sending utils/TableGen/ClangAttrEmitter.cpp Transmitting file data ...............done Committing transaction... Committed revision 326862.

nico avatar Mar 07 '18 02:03 nico

repro, main TU $ cat precompile.h #include <stdlib.h>

$ ../../../../llvm-build-goma/bin/clang -fno-strict-aliasing -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64 -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -Wno-null-pointer-arithmetic -fno-omit-frame-pointer -gdwarf-2 -isysroot ../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.9.0 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-char-subscripts -Wglobal-constructors -Wexit-time-destructors -Wexit-time-destructors -Wshadow -Wexit-time-destructors -O2 -std=c++14 -stdlib=libc++ -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -x c++-header precompile.h -o precompile.h-cc.gch

$ ../../../../llvm-build-goma/bin/clang++ -DSYSTEM_NATIVE_UTF8 -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_XCODE_VERSION=0920 -D_FORTIFY_SOURCE=2 -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DBASE_IMPLEMENTATION -I../.. -Iclang_x64/gen -fno-strict-aliasing -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64 -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -Wno-null-pointer-arithmetic -fno-omit-frame-pointer -gdwarf-2 -isysroot $(xcrun -show-sdk-path) -mmacosx-version-min=10.9.0 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-char-subscripts -Wglobal-constructors -Wexit-time-destructors -Wexit-time-destructors -Wshadow -Wexit-time-destructors -O2 -std=c++14 -stdlib=libc++ -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -include precompile.h-cc -c foo.cc -o clang_x64/obj/base/base/file_enumerator_posix.o

nico avatar Mar 07 '18 01:03 nico

../../../../llvm-build-goma/bin/clang++ -MMD -MF clang_x64/obj/base/base/file_enumerator_posix.o.d -DSYSTEM_NATIVE_UTF8 -DV8_DEPRECATION_WARNINGS -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -DCR_XCODE_VERSION=0920 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_FORTIFY_SOURCE=2 -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DBASE_IMPLEMENTATION -I../.. -Iclang_x64/gen -fno-strict-aliasing -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -fcolor-diagnostics -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64 -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-inconsistent-missing-override -Wno-undefined-var-template -Wno-nonportable-include-path -Wno-address-of-packed-member -Wno-unused-lambda-capture -Wno-user-defined-warnings -Wno-enum-compare-switch -Wno-null-pointer-arithmetic -fno-omit-frame-pointer -gdwarf-2 -isysroot ../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.9.0 -fvisibility=hidden -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-char-subscripts -Wglobal-constructors -Wexit-time-destructors -Wexit-time-destructors -Wshadow -Wexit-time-destructors -O2 -std=c++14 -stdlib=libc++ -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -include clang_x64/obj/base/base/precompile.h-cc -c ../../base/files/file_enumerator_posix.cc -o clang_x64/obj/base/base/file_enumerator_posix.o

I can repro locally, but it requires a precompiled header, so the repro will be slightly gnarly.

nico avatar Mar 07 '18 01:03 nico

assigned to @jdenny-ornl

nico avatar Mar 06 '18 21:03 nico