[lld] [llvm] [LLD] [COFF] Fix linking MSVC generated implib header objects (PR #122811)
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 19:57:05 PST 2025
thurstond wrote:
The buildbot is missing some of the test output, but I re-ran the buildbot locally:
```
******************** TEST 'lld :: COFF/empty-section-decl.yaml' FAILED ********************
Exit Code: 1
Command Output (stderr):
--
RUN: at line 3: /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/bin/yaml2obj /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/test/COFF/empty-section-decl.yaml -o /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/test/COFF/Output/empty-section-decl.yaml.tmp.obj
+ /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/bin/yaml2obj /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/test/COFF/empty-section-decl.yaml -o /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/test/COFF/Output/empty-section-decl.yaml.tmp.obj
RUN: at line 4: /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/bin/lld-link -dll -out:/usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/test/COFF/Output/empty-section-decl.yaml.tmp.dll /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/test/COFF/Output/empty-section-decl.yaml.tmp.obj -noentry -subsystem:console -lldmap:/usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/test/COFF/Output/empty-section-decl.yaml.tmp.map
+ /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/bin/lld-link -dll -out:/usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/test/COFF/Output/empty-section-decl.yaml.tmp.dll /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/test/COFF/Output/empty-section-decl.yaml.tmp.obj -noentry -subsystem:console -lldmap:/usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/test/COFF/Output/empty-section-decl.yaml.tmp.map
=================================================================
==2780289==ERROR: AddressSanitizer: use-after-poison on address 0x7e0b87e28d28 at pc 0x55a979a99e7e bp 0x7ffe4b18f0b0 sp 0x7ffe4b18f0a8
READ of size 1 at 0x7e0b87e28d28 thread T0
#0 0x55a979a99e7d in getStorageClass /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Object/COFF.h:344
#1 0x55a979a99e7d in isSectionDefinition /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Object/COFF.h:429:9
#2 0x55a979a99e7d in getSymbols /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/LLDMapFile.cpp:54:42
#3 0x55a979a99e7d in lld::coff::writeLLDMapFile(lld::coff::COFFLinkerContext const&) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/LLDMapFile.cpp:103:40
#4 0x55a979a16879 in (anonymous namespace)::Writer::run() /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Writer.cpp:810:3
#5 0x55a979a00aac in lld::coff::writeResult(lld::coff::COFFLinkerContext&) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Writer.cpp:354:15
#6 0x55a97985f7ed in lld::coff::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:2826:3
#7 0x55a97984cdd3 in lld::coff::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:97:15
#8 0x55a9797f9793 in lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/Common/DriverDispatcher.cpp:163:12
#9 0x55a9797fa3b6 in operator() /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/Common/DriverDispatcher.cpp:188:15
#10 0x55a9797fa3b6 in void llvm::function_ref<void ()>::callback_fn<lld::lldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>)::$_0>(long) /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#11 0x55a97966cb93 in operator() /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
#12 0x55a97966cb93 in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:3
#13 0x55a9797f9dc3 in lld::lldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/Common/DriverDispatcher.cpp:187:14
#14 0x55a979627512 in lld_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/tools/lld/lld.cpp:103:14
#15 0x55a979628731 in main /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/tools/lld/lld-driver.cpp:17:10
#16 0x7ffb8b202c89 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#17 0x7ffb8b202d44 in __libc_start_main csu/../csu/libc-start.c:360:3
#18 0x55a97953ef60 in _start (/usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/bin/lld+0x8fd1f60)
0x7e0b87e28d28 is located 40 bytes inside of 4096-byte region [0x7e0b87e28d00,0x7e0b87e29d00)
allocated by thread T0 here:
#0 0x55a9796259a2 in operator new(unsigned long, std::align_val_t) /usr/local/google/home/thurston/buildbot_repro/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:98:3
#1 0x55a97969d28e in Allocate /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Support/AllocatorBase.h:92:12
#2 0x55a97969d28e in StartNewSlab /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Support/Allocator.h:346:42
#3 0x55a97969d28e in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::AllocateSlow(unsigned long, unsigned long, llvm::Align) /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Support/Allocator.h:202:5
#4 0x55a979931f28 in Allocate /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Support/Allocator.h:178:12
#5 0x55a979931f28 in Allocate /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Support/Allocator.h:216:12
#6 0x55a979931f28 in Allocate /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Support/AllocatorBase.h:53:43
#7 0x55a979931f28 in Allocate<llvm::object::coff_symbol_generic> /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Support/AllocatorBase.h:76:29
#8 0x55a979931f28 in Allocate /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Support/Allocator.h:439:50
#9 0x55a979931f28 in make<llvm::object::coff_symbol_generic, const llvm::object::coff_symbol_generic &> /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/include/lld/Common/Memory.h:61:46
#10 0x55a979931f28 in lld::coff::ObjFile::createRegular(llvm::object::COFFSymbolRef) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/InputFiles.cpp:464:28
#11 0x55a979934004 in lld::coff::ObjFile::createDefined(llvm::object::COFFSymbolRef, std::__1::vector<llvm::object::coff_aux_section_definition const*, std::__1::allocator<llvm::object::coff_aux_section_definition const*>>&, bool&) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/InputFiles.cpp:855:10
#12 0x55a97992a5eb in lld::coff::ObjFile::initializeSymbols() /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/InputFiles.cpp:522:20
#13 0x55a9799296d5 in lld::coff::ObjFile::parse() /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/InputFiles.cpp:248:3
#14 0x55a979862534 in lld::coff::LinkerDriver::addFile(lld::coff::InputFile*) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:212:11
#15 0x55a979866b67 in lld::coff::LinkerDriver::addBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, bool, bool) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp
#16 0x55a97988b704 in operator() /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:358:18
#17 0x55a97988b704 in __invoke<(lambda at /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:323:15) &> /usr/local/google/home/thurston/buildbot_repro/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:179:25
#18 0x55a97988b704 in __call<(lambda at /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:323:15) &> /usr/local/google/home/thurston/buildbot_repro/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:251:5
#19 0x55a97988b704 in __invoke_r<void, (lambda at /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:323:15) &> /usr/local/google/home/thurston/buildbot_repro/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:273:10
#20 0x55a97988b704 in operator() /usr/local/google/home/thurston/buildbot_repro/libcxx_build_asan/include/c++/v1/__functional/function.h:167:12
#21 0x55a97988b704 in std::__1::__function::__func<lld::coff::LinkerDriver::enqueuePath(llvm::StringRef, bool, bool)::$_0, std::__1::allocator<lld::coff::LinkerDriver::enqueuePath(llvm::StringRef, bool, bool)::$_0>, void ()>::operator()() /usr/local/google/home/thurston/buildbot_repro/libcxx_build_asan/include/c++/v1/__functional/function.h:319:10
#22 0x55a979876c06 in operator() /usr/local/google/home/thurston/buildbot_repro/libcxx_build_asan/include/c++/v1/__functional/function.h:436:12
#23 0x55a979876c06 in operator() /usr/local/google/home/thurston/buildbot_repro/libcxx_build_asan/include/c++/v1/__functional/function.h:995:10
#24 0x55a979876c06 in lld::coff::LinkerDriver::run() /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:1086:5
#25 0x55a97985ac7e in lld::coff::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:2258:3
#26 0x55a97984cdd3 in lld::coff::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/COFF/Driver.cpp:97:15
#27 0x55a9797f9793 in lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/Common/DriverDispatcher.cpp:163:12
#28 0x55a9797fa3b6 in operator() /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/Common/DriverDispatcher.cpp:188:15
#29 0x55a9797fa3b6 in void llvm::function_ref<void ()>::callback_fn<lld::lldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>)::$_0>(long) /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#30 0x55a97966cb93 in operator() /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
#31 0x55a97966cb93 in llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:3
#32 0x55a9797f9dc3 in lld::lldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/Common/DriverDispatcher.cpp:187:14
#33 0x55a979627512 in lld_main(int, char**, llvm::ToolContext const&) /usr/local/google/home/thurston/buildbot_repro/llvm-project/lld/tools/lld/lld.cpp:103:14
#34 0x55a979628731 in main /usr/local/google/home/thurston/buildbot_repro/llvm_build_asan/tools/lld/tools/lld/lld-driver.cpp:17:10
#35 0x7ffb8b202c89 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
SUMMARY: AddressSanitizer: use-after-poison /usr/local/google/home/thurston/buildbot_repro/llvm-project/llvm/include/llvm/Object/COFF.h:344 in getStorageClass
Shadow bytes around the buggy address:
0x7e0b87e28a80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x7e0b87e28b00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x7e0b87e28b80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x7e0b87e28c00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x7e0b87e28c80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x7e0b87e28d00: 00 00 00 00 04[f7]f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x7e0b87e28d80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x7e0b87e28e00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x7e0b87e28e80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x7e0b87e28f00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x7e0b87e28f80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
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
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
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
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==2780289==ABORTING
```
https://github.com/llvm/llvm-project/pull/122811
More information about the llvm-commits
mailing list