llvm-6502/test/Linker
Chandler Carruth e82f41785f Revert r221014: "Refactor duplicated code in liking GlobalValues."
This commit introduces heap-use-after-free detected by ASan. Here is the output
for one of several tests that detect it:

******************** TEST 'LLVM :: Linker/AppendingLinkage.ll' FAILED ********************
Command Output (stderr):
--
=================================================================
==2122==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c00000b9c8 at pc 0x0000005d05d1 bp 0x7fff64ed27c0 sp 0x7fff64ed27b8
READ of size 4 at 0x60c00000b9c8 thread T0
    #0 0x5d05d0 in llvm::GlobalValue::setUnnamedAddr(bool) /usr/local/google/home/chandlerc/src/llvm/build/../include/llvm/IR/GlobalValue.h:115:35
    #1 0x69fff1 in (anonymous namespace)::ModuleLinker::linkGlobalValueProto(llvm::GlobalValue*) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1041:5
    #2 0x697229 in (anonymous namespace)::ModuleLinker::run() /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1485:9
    #3 0x696542 in llvm::Linker::linkInModule(llvm::Module*) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1621:10
    #4 0x4a2db7 in main /usr/local/google/home/chandlerc/src/llvm/build/../tools/llvm-link/llvm-link.cpp:116:9
    #5 0x7f4ae61e5ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287
    #6 0x41eb71 in _start (/usr/local/google/home/chandlerc/src/llvm/build/bin/llvm-link+0x41eb71)

0x60c00000b9c8 is located 72 bytes inside of 128-byte region [0x60c00000b980,0x60c00000ba00)
freed by thread T0 here:
    #0 0x4a1e6b in operator delete(void*) /usr/local/google/home/chandlerc/src/llvm/opt-build/../projects/compiler-rt/lib/asan/asan_new_delete.cc:94:3
    #1 0x5d1a7a in llvm::iplist<llvm::GlobalVariable, llvm::ilist_traits<llvm::GlobalVariable> >::erase(llvm::ilist_iterator<llvm::GlobalVariable>) /usr/local/google/home/chandlerc/src/llvm/build/../inclu
de/llvm/ADT/ilist.h:466:5
    #2 0x5d1980 in llvm::GlobalVariable::eraseFromParent() /usr/local/google/home/chandlerc/src/llvm/build/../lib/IR/Globals.cpp:204:3
    #3 0x6a8a4d in (anonymous namespace)::ModuleLinker::linkAppendingVarProto(llvm::GlobalVariable*, llvm::GlobalVariable const*) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.
cpp:980:3
    #4 0x6a7403 in (anonymous namespace)::ModuleLinker::linkGlobalVariableProto(llvm::GlobalVariable const*, llvm::GlobalValue*, bool) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkMod
ules.cpp:1074:11
    #5 0x69ff4e in (anonymous namespace)::ModuleLinker::linkGlobalValueProto(llvm::GlobalValue*) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1028:13
    #6 0x697229 in (anonymous namespace)::ModuleLinker::run() /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1485:9
    #7 0x696542 in llvm::Linker::linkInModule(llvm::Module*) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1621:10
    #8 0x4a2db7 in main /usr/local/google/home/chandlerc/src/llvm/build/../tools/llvm-link/llvm-link.cpp:116:9
    #9 0x7f4ae61e5ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287

previously allocated by thread T0 here:
    #0 0x4a192b in operator new(unsigned long) /usr/local/google/home/chandlerc/src/llvm/opt-build/../projects/compiler-rt/lib/asan/asan_new_delete.cc:62:35
    #1 0x61d85c in llvm::User::operator new(unsigned long, unsigned int) /usr/local/google/home/chandlerc/src/llvm/build/../lib/IR/User.cpp:57:19
    #2 0x6a7525 in (anonymous namespace)::ModuleLinker::linkGlobalVariableProto(llvm::GlobalVariable const*, llvm::GlobalValue*, bool) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkMod
ules.cpp:1100:3
    #3 0x69ff4e in (anonymous namespace)::ModuleLinker::linkGlobalValueProto(llvm::GlobalValue*) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1028:13
    #4 0x697229 in (anonymous namespace)::ModuleLinker::run() /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1485:9
    #5 0x696542 in llvm::Linker::linkInModule(llvm::Module*) /usr/local/google/home/chandlerc/src/llvm/build/../lib/Linker/LinkModules.cpp:1621:10
    #6 0x4a2db7 in main /usr/local/google/home/chandlerc/src/llvm/build/../tools/llvm-link/llvm-link.cpp:116:9
    #7 0x7f4ae61e5ec4 in __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287

SUMMARY: AddressSanitizer: heap-use-after-free /usr/local/google/home/chandlerc/src/llvm/build/../include/llvm/IR/GlobalValue.h:115 llvm::GlobalValue::setUnnamedAddr(bool)
Shadow bytes around the buggy address:
  0x0c187fff96e0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c187fff96f0: 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa fa
  0x0c187fff9700: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa
  0x0c187fff9710: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c187fff9720: 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa
=>0x0c187fff9730: fd fd fd fd fd fd fd fd fd[fd]fd fd fd fd fd fd
  0x0c187fff9740: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c187fff9750: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
  0x0c187fff9760: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c187fff9770: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c187fff9780: fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  ASan internal:           fe
==2122==ABORTING

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221096 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-02 09:10:31 +00:00
..
Inputs Revert r221014: "Refactor duplicated code in liking GlobalValues." 2014-11-02 09:10:31 +00:00
2002-07-17-GlobalFail.ll
2002-07-17-LinkTest2.ll
2002-08-20-ConstantExpr.ll
2003-01-30-LinkerRename.ll Make this test a bit stricter. 2014-10-23 18:44:07 +00:00
2003-01-30-LinkerTypeRename.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2003-04-23-LinkOnceLost.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2003-04-26-NullPtrLinkProblem.ll
2003-05-15-TypeProblem.ll
2003-05-31-LinkerRename.ll Make this test a bit stricter. 2014-10-23 18:52:46 +00:00
2003-06-02-TypeResolveProblem2.ll
2003-06-02-TypeResolveProblem.ll
2003-08-20-OpaqueTypeResolve.ll
2003-08-23-GlobalVarLinking.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2003-08-23-RecursiveOpaqueTypeResolve.ll
2003-08-24-InheritPtrSize.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2003-08-28-TypeResolvesGlobal2.ll
2003-08-28-TypeResolvesGlobal3.ll
2003-08-28-TypeResolvesGlobal.ll
2003-10-27-LinkOncePromote.ll
2003-11-18-TypeResolution.ll
2004-02-17-WeakStrongLinkage.ll
2004-05-07-TypeResolution1.ll
2004-05-07-TypeResolution2.ll
2004-12-03-DisagreeingType.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2005-02-12-ConstantGlobals-2.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2005-02-12-ConstantGlobals.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2005-12-06-AppendingZeroLengthArrays.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2006-01-19-ConstantPacked.ll
2006-06-15-GlobalVarAlignment.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2008-03-05-AliasReference2.ll
2008-03-05-AliasReference.ll Use "weak alias" instead of "alias weak" 2014-07-30 22:51:54 +00:00
2008-03-07-DroppedSection_a.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2008-03-07-DroppedSection_b.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2008-06-13-LinkOnceRedefinition.ll
2008-06-26-AddressSpace.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
2008-07-06-AliasFnDecl2.ll
2008-07-06-AliasFnDecl.ll
2008-07-06-AliasWeakDest2.ll
2008-07-06-AliasWeakDest.ll
2009-09-03-mdnode2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2009-09-03-mdnode.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-04-DebugLoc2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-04-DebugLoc.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-04-Metadata2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-04-Metadata.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-18-unique-class-type2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-18-unique-class-type.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-18-unique-debug-type2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-18-unique-debug-type.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
2011-08-22-ResolveAlias2.ll Use "weak alias" instead of "alias weak" 2014-07-30 22:51:54 +00:00
2011-08-22-ResolveAlias.ll Use "weak alias" instead of "alias weak" 2014-07-30 22:51:54 +00:00
alias.ll Allow alias to point to an arbitrary ConstantExpr. 2014-06-03 02:41:57 +00:00
AppendingLinkage2.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
AppendingLinkage.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
available_externally_a.ll
available_externally_b.ll
basiclink.ll
comdat2.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat3.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat4.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat5.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat6.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
comdat7.ll Cleanup this test a bit. 2014-10-23 19:36:21 +00:00
comdat8.ll Cleanup this test a bit. 2014-10-23 19:23:42 +00:00
comdat9.ll Set comdats when lazily linking functions. 2014-08-15 20:17:08 +00:00
comdat.ll IR: Add COMDATs to the IR 2014-06-27 18:19:56 +00:00
ConstantGlobals.ll merge tests for constant linking. 2014-10-31 05:04:16 +00:00
constructor-comdat.ll Fix use of uninitialized variable. 2014-08-11 17:07:34 +00:00
ctors.ll Fix pr20078. 2014-09-05 21:27:52 +00:00
datalayout.ll Don't assume an empty stderr. 2014-03-11 18:25:33 +00:00
DbgDeclare2.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
DbgDeclare.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
debug-info-version-a.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
debug-info-version-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
dllstorage-a.ll Copy dll storage in copyAttributes. 2014-02-13 05:11:35 +00:00
dllstorage-b.ll Copy dll storage in copyAttributes. 2014-02-13 05:11:35 +00:00
func-attrs-a.ll Verify that attributes are not lost during linking. 2014-01-24 19:20:15 +00:00
func-attrs-b.ll Verify that attributes are not lost during linking. 2014-01-24 19:20:15 +00:00
global_ctors.ll Don't upgrade global constructors when reading bitcode 2014-08-12 16:46:37 +00:00
inlineasm.ll
link-global-to-func.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
link-type-names.ll
linkage2.ll Merge alignment of common GlobalValue. 2014-09-09 17:48:18 +00:00
linkage.ll
linkmdnode2.ll
linkmdnode.ll
linknamedmdnode2.ll
linknamedmdnode.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00
LinkOnce.ll
metadata-a.ll
metadata-b.ll
module-flags-1-a.ll
module-flags-1-b.ll
module-flags-2-a.ll
module-flags-2-b.ll
module-flags-3-a.ll
module-flags-3-b.ll
module-flags-4-a.ll
module-flags-4-b.ll
module-flags-5-a.ll
module-flags-5-b.ll
module-flags-6-a.ll
module-flags-6-b.ll
module-flags-7-a.ll
module-flags-7-b.ll
module-flags-8-a.ll [IR] Add 'Append' and 'AppendUnique' module flag behaviors. 2013-01-16 21:38:56 +00:00
module-flags-8-b.ll [IR] Add 'Append' and 'AppendUnique' module flag behaviors. 2013-01-16 21:38:56 +00:00
multiple-merged-structs.ll
partial-type-refinement-link.ll
partial-type-refinement.ll
PR8300.ll
prefixdata.ll Implement function prefix data as an IR feature. 2013-09-16 01:08:15 +00:00
redefinition.ll Unify and update link-messages.ll and redefinition.ll. NFC. 2014-10-31 16:52:30 +00:00
targettriple.ll Add a test for the -suppress-warnings option. 2014-10-25 01:14:15 +00:00
testlink1.ll
testlink2.ll
transitive-lazy-link.ll [tests] Use multiple statements instead of 'echo -e', which is not part of BSD echo. 2013-08-29 03:02:30 +00:00
type-unique-inheritance.ll Debug Info: In DIBuilder, the context fields of a TAG_inheritance and a 2013-09-09 23:07:58 +00:00
type-unique-odr-a.ll [dwarfdump] Print the name for referenced specification of abstract_origin DIEs. 2014-10-06 03:36:31 +00:00
type-unique-odr-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-simple2-a.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-simple2-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-simple2.ll Reland r200340 - 'Add line table debug info to COFF files when using a win32 triple' 2014-01-30 01:39:17 +00:00
type-unique-simple-a.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-simple-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-type-array-a.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
type-unique-type-array-b.ll Revert "Revert "DI: Fold constant arguments into a single MDString"" 2014-10-03 20:01:09 +00:00
unnamed-addr1-a.ll Allow aliases to be unnamed_addr. 2014-06-06 01:20:28 +00:00
unnamed-addr1-b.ll Make this input file pass the verifier. 2014-09-09 15:40:12 +00:00
unnamed-addr-err-a.ll Error on linking appending globals with different unnamed_addr. 2013-09-04 15:33:34 +00:00
unnamed-addr-err-b.ll Error on linking appending globals with different unnamed_addr. 2013-09-04 15:33:34 +00:00
visibility.ll Revert r221014: "Refactor duplicated code in liking GlobalValues." 2014-11-02 09:10:31 +00:00
weakextern.ll Rewrite test/Linker tests to use FileCheck instead of grep. 2013-04-09 16:51:13 +00:00