Closed Quuxplusone closed 9 years ago
Attached MacOSKeychainAPIChecker-41c425.cpp.xz
(751504 bytes, application/force-download): MacOSKeychainAPIChecker-41c425.cpp.xz
Attached MacOSKeychainAPIChecker-41c425.log
(7908 bytes, text/x-log): MacOSKeychainAPIChecker-41c425.log
Attached MacOSKeychainAPIChecker-41c425.sh
(1264 bytes, application/x-shellscript): MacOSKeychainAPIChecker-41c425.sh
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
* thread #1: tid = 22354, 0x00007fffe82638c7 libc.so.6`__GI_raise(sig=6) + 55
at raise.c:55, name = 'clang-3.7', stop reason = signal SIGABRT
frame #0: 0x00007fffe82638c7 libc.so.6`__GI_raise(sig=6) + 55 at raise.c:55
52 if (__glibc_unlikely (pid <= 0))
53 pid = (pid & INT_MAX) == 0 ? selftid : -pid;
54
-> 55 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
56 }
57 libc_hidden_def (raise)
58 weak_alias (raise, gsignal)
(lldb) bt
* thread #1: tid = 22354, 0x00007fffe82638c7 libc.so.6`__GI_raise(sig=6) + 55
at raise.c:55, name = 'clang-3.7', stop reason = signal SIGABRT
* frame #0: 0x00007fffe82638c7 libc.so.6`__GI_raise(sig=6) + 55 at raise.c:55
frame #1: 0x00007fffe826552a libc.so.6`__GI_abort + 362 at abort.c:89
frame #2: 0x00007fffe825c46d libc.so.6`__assert_fail_base(fmt=<unavailable>, assertion=<unavailable>, file=<unavailable>, line=<unavailable>, function=<unavailable>) + 285 at assert.c:92
frame #3: 0x00007fffe825c522 libc.so.6`__GI___assert_fail(assertion=<unavailable>, file=<unavailable>, line=<unavailable>, function=<unavailable>) + 66 at assert.c:101
frame #4: 0x00007fffe7d8de98 libLLVMAsmPrinter.so`llvm::DwarfFile::addScopeVariable(this=0x0000000008a31a80, LS=0x000000000b7b6560, Var=0x000000000b7d7170) + 248 at DwarfFile.cpp:171
frame #5: 0x00007fffe7d5ba7f libLLVMAsmPrinter.so`llvm::DwarfDebug::collectVariableInfoFromMMITable(this=0x0000000008a30db0, Processed=0x00007fffffff8cf0) + 799 at DwarfDebug.cpp:789
frame #6: 0x00007fffe7d5d784 libLLVMAsmPrinter.so`llvm::DwarfDebug::collectVariableInfo(this=0x0000000008a30db0, TheCU=0x00000000061bc2a0, SP=DISubprogram at 0x00007fffffff8a58, Processed=0x00007fffffff8cf0) + 68 at DwarfDebug.cpp:940
frame #7: 0x00007fffe7d606af libLLVMAsmPrinter.so`llvm::DwarfDebug::endFunction(this=0x0000000008a30db0, MF=0x000000000bc47580) + 575 at DwarfDebug.cpp:1263
frame #8: 0x00007fffe7cf61bb libLLVMAsmPrinter.so`llvm::AsmPrinter::EmitFunctionBody(this=0x0000000005f699e0) + 2619 at AsmPrinter.cpp:885
frame #9: 0x00007fffef167a0c libLLVMX86CodeGen.so`llvm::X86AsmPrinter::runOnMachineFunction(this=0x0000000005f699e0, MF=0x000000000bc47580) + 300 at X86AsmPrinter.cpp:70
frame #10: 0x00007fffeccdc68e libLLVMCodeGen.so`llvm::MachineFunctionPass::runOnFunction(this=0x0000000005f699e0, F=0x0000000009c2d980) + 110 at MachineFunctionPass.cpp:41
frame #11: 0x00007fffec6836bd libLLVMCore.so`llvm::FPPassManager::runOnFunction(this=0x000000000668ea80, F=0x0000000009c2d980) + 413 at LegacyPassManager.cpp:1538
frame #12: 0x00007fffec683bf8 libLLVMCore.so`llvm::FPPassManager::runOnModule(this=0x000000000668ea80, M=0x0000000000677850) + 104 at LegacyPassManager.cpp:1558
frame #13: 0x00007fffec684553 libLLVMCore.so`(anonymous namespace)::MPPassManager::runOnModule(this=0x00000000093c5a20, M=0x0000000000677850) + 1283 at LegacyPassManager.cpp:1616
frame #14: 0x00007fffec683eae libLLVMCore.so`llvm::legacy::PassManagerImpl::run(this=0x000000000632bf80, M=0x0000000000677850) + 302 at LegacyPassManager.cpp:1723
frame #15: 0x00007fffec684d41 libLLVMCore.so`llvm::legacy::PassManager::run(this=0x0000000000fa1f40, M=0x0000000000677850) + 33 at LegacyPassManager.cpp:1756
frame #16: 0x00007fffe3249173 libclangCodeGen.so`(anonymous namespace)::EmitAssemblyHelper::EmitAssembly(this=0x00007fffffff99d0, Action=Backend_EmitObj, OS=0x000000000066f720) + 1523 at BackendUtil.cpp:640
frame #17: 0x00007fffe32488d2 libclangCodeGen.so`clang::EmitBackendOutput(Diags=0x0000000000644f30, CGOpts=0x0000000000641b90, TOpts=0x0000000000642160, LOpts=0x0000000000642020, TDesc=(Data = "e-m:e-i64:64-f80:128-n8:16:32:64-S128", Length = 37), M=0x0000000000677850, Action=Backend_EmitObj, OS=0x000000000066f720) + 114 at BackendUtil.cpp:652
frame #18: 0x00007fffe34d9706 libclangCodeGen.so`clang::BackendConsumer::HandleTranslationUnit(this=0x00000000006773d0, C=0x0000000000669ec0) + 1270 at CodeGenAction.cpp:174
frame #19: 0x00007fffe5009e96 libclangParse.so`clang::ParseAST(S=0x0000000000692eb0, PrintStats=false, SkipFunctionBodies=false) + 1206 at ParseAST.cpp:151
frame #20: 0x00007fffe92729ba libclangFrontend.so`clang::ASTFrontendAction::ExecuteAction(this=0x0000000000642cc0) + 522 at FrontendAction.cpp:535
frame #21: 0x00007fffe34d7e51 libclangCodeGen.so`clang::CodeGenAction::ExecuteAction(this=0x0000000000642cc0) + 3713 at CodeGenAction.cpp:725
frame #22: 0x00007fffe9271cc0 libclangFrontend.so`clang::FrontendAction::Execute(this=0x0000000000642cc0) + 112 at FrontendAction.cpp:437
frame #23: 0x00007fffe92060db libclangFrontend.so`clang::CompilerInstance::ExecuteAction(this=0x0000000000641a20, Act=0x0000000000642cc0) + 891 at CompilerInstance.cpp:802
frame #24: 0x00007fffe8e93368 libclangFrontendTool.so`clang::ExecuteCompilerInvocation(Clang=0x0000000000641a20) + 3032 at ExecuteCompilerInvocation.cpp:222
frame #25: 0x000000000041899b clang-3.7`cc1_main(Argv=ArrayRef<const char *> at 0x00007fffffffb468, Argv0=0x00007fffffffd87b, MainAddr=0x000000000040af60) + 2299 at cc1_main.cpp:110
frame #26: 0x000000000040ccf3 clang-3.7`ExecuteCC1Tool(argv=ArrayRef<const char *> at 0x00007fffffffb9e8, Tool=(Data = "", Length = 0)) + 163 at driver.cpp:369
frame #27: 0x000000000040b4bc clang-3.7`main(argc_=77, argv_=0x00007fffffffd268) + 1212 at driver.cpp:415
frame #28: 0x00007fffe824efe0 libc.so.6`__libc_start_main(main=0x000000000040b000, argc=77, argv=0x00007fffffffd268, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffd258) + 240 at libc-start.c:289
frame #29: 0x000000000040ae84 clang-3.7`_start + 41
(lldb) f 4
frame #4: 0x00007fffe7d8de98
libLLVMAsmPrinter.so`llvm::DwarfFile::addScopeVariable(this=0x0000000008a31a80,
LS=0x000000000b7b6560, Var=0x000000000b7d7170) + 248 at DwarfFile.cpp:171
168 // A later indexed parameter has been found, insert immediately before it.
169 if (CurNum > ArgNum)
170 break;
-> 171 assert(CurNum != ArgNum && "Duplicate argument");
172 ++I;
173 }
174 Vars.insert(I, Var);
(lldb) expr CurNum
(unsigned int) $0 = 5
(lldb) expr ArgNum
(unsigned int) $1 = 5
(lldb) expr I
(llvm::DbgVariable **) $2 = 0x000000000b87fb30
(lldb) fr v
(llvm::DwarfFile *) this = 0x0000000008a31a80
(llvm::LexicalScope *) LS = 0x000000000b7b6560
(llvm::DbgVariable *) Var = 0x000000000b7d7170
(llvm::SmallVectorImpl<llvm::DbgVariable *> &) Vars = 0x000000000b87fb18: {
llvm::SmallVectorTemplateBase<llvm::DbgVariable *, true> = {
llvm::SmallVectorTemplateCommon<llvm::DbgVariable *> = {
llvm::SmallVectorBase = (BeginX = 0x000000000b87fb30, EndX = 0x000000000b87fb38, CapacityX = 0x000000000b87fb70)
FirstEl = {
llvm::AlignedCharArray<8, 8> = (buffer = "<c0>x88\v")
}
}
}
}
(llvm::DIVariable) DV = {
llvm::DIDescriptor = {
DbgNode = 0x0000000009329d88
}
}
Attached MacOSKeychainAPIChecker-41c425.lldb.log
(12285 bytes, text/x-log): MacOSKeychainAPIChecker-41c425.lldb.log
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.
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 <class x8> 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.
(In reply to comment #7)
> 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 <class x8> 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?
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
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.
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 PR22502.
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
It bootstraps successfully now (r228827).
Thanks for the quick response!
MacOSKeychainAPIChecker-41c425.cpp.xz
(751504 bytes, application/force-download)MacOSKeychainAPIChecker-41c425.log
(7908 bytes, text/x-log)MacOSKeychainAPIChecker-41c425.sh
(1264 bytes, application/x-shellscript)MacOSKeychainAPIChecker-41c425.lldb.log
(12285 bytes, text/x-log)