llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.48k stars 11.77k forks source link

llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp:171: void llvm::DwarfFile::addScopeVariable(llvm::LexicalScope *, llvm::DbgVariable *): Assertion `CurNum != ArgNum && "Duplicate argument"' failed. #22876

Closed llvmbot closed 9 years ago

llvmbot commented 9 years ago
Bugzilla Link 22502
Resolution FIXED
Resolved on Feb 11, 2015 08:08
Version trunk
OS Linux
Attachments MacOSKeychainAPIChecker-41c425.cpp.xz, MacOSKeychainAPIChecker-41c425.log, MacOSKeychainAPIChecker-41c425.sh
Reporter LLVM Bugzilla Contributor
CC @adrian-prantl,@dwblaikie,@echristo

Extended Description

LLVM trunk: 228493 Clang trunk: 228492 Bootstrap STAGE2 failed.

clang-3.7: /home/chilledheart/sources-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp:171: void llvm::DwarfFile::addScopeVariable(llvm::LexicalScope , llvm::DbgVariable ): Assertion `CurNum != ArgNum && "Duplicate argument"' failed.

​0 0x7fc92272738e llvm::sys::PrintStackTrace(_IO_FILE*) /home/chilledheart/sources-llvm/llvm/lib/Support/Unix/Signals.inc:422:15

​1 0x7fc9227289ab PrintStackTraceSignalHandler(void*) /home/chilledheart/sources-llvm/llvm/lib/Support/Unix/Signals.inc:481:1

​2 0x7fc92272ac6b SignalHandler(int) /home/chilledheart/sources-llvm/llvm/lib/Support/Unix/Signals.inc:198:60

​3 0x7fc9203a2950 __restore_rt (/lib64/libc.so.6+0x34950)

​4 0x7fc9203a28c7 __GI_raise /usr/src/debug/glibc-2.20/signal/../sysdeps/unix/sysv/linux/raise.c:55:0

​5 0x7fc9203a452a __GI_abort /usr/src/debug/glibc-2.20/stdlib/abort.c:91:0

​6 0x7fc92039b46d __assert_fail_base /usr/src/debug/glibc-2.20/assert/assert.c:92:0

​7 0x7fc92039b522 (/lib64/libc.so.6+0x2d522)

​8 0x7fc91fecce98 llvm::DwarfFile::addScopeVariable(llvm::LexicalScope, llvm::DbgVariable) /home/chilledheart/sources-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp:172:7

​9 0x7fc91fe9aa7f llvm::DwarfDebug::collectVariableInfoFromMMITable(llvm::SmallPtrSetImpl<llvm::MDNode const*>&) /home/chilledheart/sources-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:773:23

​10 0x7fc91fe9c784 llvm::DwarfDebug::collectVariableInfo(llvm::DwarfCompileUnit&, llvm::DISubprogram, llvm::SmallPtrSetImpl<llvm::MDNode const*>&) /home/chilledheart/sources-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:942:24

​11 0x7fc91fe9f6af llvm::DwarfDebug::endFunction(llvm::MachineFunction const*) /home/chilledheart/sources-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1263:3

​12 0x7fc91fe351bb llvm::AsmPrinter::EmitFunctionBody() /home/chilledheart/sources-llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:885:5

​13 0x7fc9272a6a0c llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) /home/chilledheart/sources-llvm/llvm/lib/Target/X86/X86AsmPrinter.cpp:70:3

​14 0x7fc924e1b68e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/chilledheart/sources-llvm/llvm/lib/CodeGen/MachineFunctionPass.cpp:41:10

​15 0x7fc9247c26bd llvm::FPPassManager::runOnFunction(llvm::Function&) /home/chilledheart/sources-llvm/llvm/lib/IR/LegacyPassManager.cpp:1538:23

​16 0x7fc9247c2bf8 llvm::FPPassManager::runOnModule(llvm::Module&) /home/chilledheart/sources-llvm/llvm/lib/IR/LegacyPassManager.cpp:1558:16

​17 0x7fc9247c3553 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/chilledheart/sources-llvm/llvm/lib/IR/LegacyPassManager.cpp:1616:23

​18 0x7fc9247c2eae llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/chilledheart/sources-llvm/llvm/lib/IR/LegacyPassManager.cpp:1723:16

​19 0x7fc9247c3d41 llvm::legacy::PassManager::run(llvm::Module&) /home/chilledheart/sources-llvm/llvm/lib/IR/LegacyPassManager.cpp:1756:10

​20 0x7fc91b388173 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, llvm::raw_ostream*) /home/chilledheart/sources-llvm/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:640:5

​21 0x7fc91b3878d2 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module, clang::BackendAction, llvm::raw_ostream) /home/chilledheart/sources-llvm/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:652:3

​22 0x7fc91b618706 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /home/chilledheart/sources-llvm/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:178:7

​23 0x7fc91d148e96 clang::ParseAST(clang::Sema&, bool, bool) /home/chilledheart/sources-llvm/llvm/tools/clang/lib/Parse/ParseAST.cpp:151:3

​24 0x7fc9213b19ba clang::ASTFrontendAction::ExecuteAction() /home/chilledheart/sources-llvm/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:537:1

​25 0x7fc91b616e51 clang::CodeGenAction::ExecuteAction() /home/chilledheart/sources-llvm/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:726:1

​26 0x7fc9213b0cc0 clang::FrontendAction::Execute() /home/chilledheart/sources-llvm/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:441:7

​27 0x7fc9213450db clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/chilledheart/sources-llvm/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:803:7

​28 0x7fc920fd2368 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/chilledheart/sources-llvm/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:222:18

​29 0x41899b cc1_main(llvm::ArrayRef<char const>, char const, void*) /home/chilledheart/sources-llvm/llvm/tools/clang/tools/driver/cc1_main.cpp:110:13

​30 0x40ccf3 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /home/chilledheart/sources-llvm/llvm/tools/clang/tools/driver/driver.cpp:369:12

​31 0x40b4bc main /home/chilledheart/sources-llvm/llvm/tools/clang/tools/driver/driver.cpp:415:12

​32 0x7fc92038dfe0 __libc_start_main /usr/src/debug/glibc-2.20/csu/libc-start.c:323:0

​33 0x40ae84 _start (/home/chilledheart/build-debug/bin/clang-3.7+0x40ae84)

Stack dump:

  1. Program arguments: /home/chilledheart/build-debug/bin/clang-3.7 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name MacOSKeychainAPIChecker.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu core-avx2 -momit-leaf-frame-pointer -g -dwarf-column-info -ffunction-sections -fdata-sections -D CLANG_ENABLE_ARCMT -D CLANG_ENABLE_OBJC_REWRITER -D CLANG_ENABLE_STATIC_ANALYZER -D GTEST_HAS_RTTI=0 -D _DEBUG -D _GNU_SOURCE -D STDC_CONSTANT_MACROS -D STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -O2 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Woverloaded-virtual -Wno-nested-anon-types -pedantic -std=c++11 -fdeprecated-macro -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -mstackrealign -fno-rtti -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -x c++ MacOSKeychainAPIChecker-41c425.cpp
  2. parser at end of file
  3. Code generation
  4. Running pass 'Function Pass Manager' on module 'MacOSKeychainAPIChecker-41c425.cpp'.
  5. Running pass 'X86 Assembly / Object Emitter' on function '@_ZN5clang4ento5check11DeadSymbols17_checkDeadSymbolsIN12_GLOBAL__N_123MacOSKeychainAPICheckerEEEvPvRNS0_12SymbolReaperERNS0_14CheckerContextE' MacOSKeychainAPIChecker-41c425.sh: line 1: 15356 Aborted (core dumped) "/home/chilledheart/build-debug/bin/clang-3.7" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-disable-free" "-main-file-name" "MacOSKeychainAPIChecker.cpp" "-mrelocation-model" "pic" "-pic-level" "2" "-mthread-model" "posix" "-mdisable-fp-elim" "-relaxed-aliasing" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "core-avx2" "-momit-leaf-frame-pointer" "-g" "-dwarf-column-info" "-ffunction-sections" "-fdata-sections" "-D" "CLANG_ENABLE_ARCMT" "-D" "CLANG_ENABLE_OBJC_REWRITER" "-D" "CLANG_ENABLE_STATIC_ANALYZER" "-D" "GTEST_HAS_RTTI=0" "-D" "_DEBUG" "-D" "_GNU_SOURCE" "-D" "STDC_CONSTANT_MACROS" "-D" "STDC_FORMAT_MACROS" "-D" "__STDC_LIMIT_MACROS" "-O2" "-Wall" "-W" "-Wno-unused-parameter" "-Wwrite-strings" "-Wcast-qual" "-Wmissing-field-initializers" "-Wno-long-long" "-Wcovered-switch-default" "-Wnon-virtual-dtor" "-Woverloaded-virtual" "-Wno-nested-anon-types" "-pedantic" "-std=c++11" "-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "0" "-fvisibility-inlines-hidden" "-mstackrealign" "-fno-rtti" "-fobjc-runtime=gcc" "-fno-common" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-x" "c++" "MacOSKeychainAPIChecker-41c425.cpp"
llvmbot commented 9 years ago

It bootstraps successfully now (r228827).

Thanks for the quick response!

adrian-prantl commented 9 years ago

Both failures should now be fixed:

Author: adrian adrian@91177308-0d34-0410-b5e6-96231b3b80d8 Date: Tue Feb 10 23:18:28 2015 +0000

Debug Info: Support variables that are described by more than one MMI
table entry. This happens when SROA splits up an alloca and the resulting
allocas cannot be lowered to SSA values because their address is passed
to a function.

Fixes llvm/llvm-project#22876 .

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228764

Author: adrian adrian@91177308-0d34-0410-b5e6-96231b3b80d8 Date: Tue Feb 10 23:32:56 2015 +0000

Add the missing testcase for r228764.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228766
adrian-prantl commented 9 years ago

I think what's happening is that the dbg.declares describing the SROAed allocas cannot be lowered into dbg.values, so we end up with multiple entries for the same argument (but distinct DIExpressions) in the MMI table.

The resolution may be as simple as making addScopeVariable() aware of DIExpressions.

I'll see if that is actually is the case.

adrian-prantl commented 9 years ago

clang++ -cc1 -triple arm64-apple-ios -emit-obj -disable-free -gdwarf-2 -dwarf-column-info -stdlib=libc++ -O2 -std=gnu++11 -fblocks -fcxx-exceptions -fexceptions -x c++ test.cpp

dwblaikie commented 9 years ago

I just reduced this piece of code from another bug report that triggers the same assertion:

long x0, x1; class x2; struct x3 { bool x4; x2 x5; bool x6; }; struct x7 { template static void x9(x8); }; int x10; class x2 { public: void x11(x3 x12) { x13(x12); } void x13(x3 x12) { x10 = (int *)__builtin_operator_new(x1); x7::x9(x12); } }; class x14 { public: x14(long); ~x14(); }; x2 x15; void x16() { x3 x17; x14 x18(x0); x17.x6 = x17.x4 = true; x15.x11(x17); }

I'm curious if this is the same bug.

Probably worth fixing one before spending too much time on the other - and just checking if it fixes both.

What's the -cc1 command line you used to observe the assertion failure on your reduced example there?

adrian-prantl commented 9 years ago

I just reduced this piece of code from another bug report that triggers the same assertion:

long x0, x1; class x2; struct x3 { bool x4; x2 x5; bool x6; }; struct x7 { template static void x9(x8); }; int x10; class x2 { public: void x11(x3 x12) { x13(x12); } void x13(x3 x12) { x10 = (int *)__builtin_operator_new(x1); x7::x9(x12); } }; class x14 { public: x14(long); ~x14(); }; x2 x15; void x16() { x3 x17; x14 x18(x0); x17.x6 = x17.x4 = true; x15.x11(x17); }

I'm curious if this is the same bug.

dwblaikie commented 9 years ago

Adrian - I've a sneaking suspicion this is more fallout from the SROA changes (a recent change of yours involved the possibility of creating extra variables for padding? Did that result in this assertion, or did it fail elsewhere?).

I'm still poking around with it, but just thought I'd bring it up in case it's something you know about/can figure out relatively quickly.

llvmbot commented 9 years ago

MacOSKeychainAPIChecker-41c425.lldb.log

llvmbot commented 9 years ago

While using lldb to debug with it, it shows ArgNum == CurNum, which is really confusing.

[chilledheart@fedora case]$ lldb -- $(cat MacOSKeychainAPIChecker-41c425.sh) (lldb) target create ""/home/chilledheart/build-debug/bin/clang-3.7"" Current executable set to '/home/chilledheart/build-debug/bin/clang-3.7' (x86_64). (lldb) settings set -- target.run-args '"-cc1"' '"-triple"' '"x86_64-unknown-linux-gnu"' '"-emit-obj"' '"-disable-free"' '"-main-file-name"' '"MacOSKeychainAPIChecker.cpp"' '"-mrelocation-model"' '"pic"' '"-pic-level"' '"2"' '"-mthread-model"' '"posix"' '"-mdisable-fp-elim"' '"-relaxed-aliasing"' '"-fmath-errno"' '"-masm-verbose"' '"-mconstructor-aliases"' '"-munwind-tables"' '"-fuse-init-array"' '"-target-cpu"' '"core-avx2"' '"-momit-leaf-frame-pointer"' '"-g"' '"-dwarf-column-info"' '"-ffunction-sections"' '"-fdata-sections"' '"-D"' '"CLANG_ENABLE_ARCMT"' '"-D"' '"CLANG_ENABLE_OBJC_REWRITER"' '"-D"' '"CLANG_ENABLE_STATIC_ANALYZER"' '"-D"' '"GTEST_HAS_RTTI=0"' '"-D"' '"_DEBUG"' '"-D"' '"_GNU_SOURCE"' '"-D"' '"STDC_CONSTANT_MACROS"' '"-D"' '"STDC_FORMAT_MACROS"' '"-D"' '"__STDC_LIMIT_MACROS"' '"-O2"' '"-Wall"' '"-W"' '"-Wno-unused-parameter"' '"-Wwrite-strings"' '"-Wcast-qual"' '"-Wmissing-field-initializers"' '"-Wno-long-long"' '"-Wcovered-switch-default"' '"-Wnon-virtual-dtor"' '"-Woverloaded-virtual"' '"-Wno-nested-anon-types"' '"-pedantic"' '"-std=c++11"' '"-fdeprecated-macro"' '"-ferror-limit"' '"19"' '"-fmessage-length"' '"0"' '"-fvisibility-inlines-hidden"' '"-mstackrealign"' '"-fno-rtti"' '"-fobjc-runtime=gcc"' '"-fno-common"' '"-fdiagnostics-show-option"' '"-fcolor-diagnostics"' '"-vectorize-loops"' '"-vectorize-slp"' '"-x"' '"c++"' '"MacOSKeychainAPIChecker-41c425.cpp"' (lldb) run Process 22354 launching Process 22354 launched: '/home/chilledheart/build-debug/bin/clang-3.7' (x86_64) warning: (x86_64) /lib64/libtinfo.so.5 DWARF compile unit extends beyond its bounds cu 0x00001869 at 0x00001883

warning: (x86_64) /lib64/libtinfo.so.5 DWARF compile unit extends beyond its bounds cu 0x000018e1 at 0x000018fb

warning: (x86_64) /lib64/libtinfo.so.5 DWARF compile unit extends beyond its bounds cu 0x00001987 at 0x000019a1

clang-3.7: /home/chilledheart/sources-llvm/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp:171: void llvm::DwarfFile::addScopeVariable(llvm::LexicalScope , llvm::DbgVariable ): Assertion `CurNum != ArgNum && "Duplicate argument"' failed. Process 22354 stopped

llvmbot commented 9 years ago

assigned to @adrian-prantl