Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

lld sometimes fails with VC++ /Zi builds #35993

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR37020
Status NEW
Importance P normal
Reported by Bruce Dawson (brucedawson@chromium.org)
Reported on 2018-04-05 13:55:07 -0700
Last modified on 2018-04-10 10:32:09 -0700
Version unspecified
Hardware PC Windows NT
CC llvm-bugs@lists.llvm.org, rnk@google.com, zturner@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Sometimes when linking VC++ builds of Chrome with lld there is a fatal
assertion failure. The repro is fairly simple:

> gn gen out\test --args="use_lld=true is_clang=false is_component_build=true"
> ninja.exe -C out\test base
c:/src/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe
../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False
../../third_party/llvm-build/Release+Asserts/bin/lld-link.exe /nologo
/IMPLIB:./base.dll.lib /DLL /OUT:./base.dll /PDB:./base.dll.pdb @./base.dll.rsp
Assertion failed: Indices.size() == 2, file
C:\b\rr\tmp7g7qqx\w\src\third_party\llvm\tools\lld\COFF\PDB.cpp, line 536
Wrote crash dump file "d:\dumps\lld-link.exe.153776.dmp"

This was tested from Chromium commit hash
e4518558818681e014f819330f8cc9655a616769. This bug is a 100% repro. The call
stack is:

00 lld_link!HandleAbort
01 lld_link!raise
02 lld_link!abort
03 lld_link!common_assert_to_stderr<wchar_t>
04 lld_link!common_assert
05 lld_link!_wassert
06 lld_link!translateIdSymbols
07 lld_link!mergeSymbolRecords::<unnamed-tag>::operator()
08 lld_link!llvm::codeview::forEachCodeViewRecord
09 lld_link!mergeSymbolRecords
0a lld_link!`anonymous namespace'::PDBLinker::addObjFile
0b lld_link!`anonymous namespace'::PDBLinker::addObjectsToPDB
0c lld_link!lld::coff::createPDB
0d lld_link!`anonymous namespace'::Writer::run
0e lld_link!lld::coff::writeResult
0f lld_link!lld::coff::LinkerDriver::link
10 lld_link!lld::coff::link
11 lld_link!main
12 lld_link!invoke_main
13 lld_link!__scrt_common_main_seh
14 kernel32!BaseThreadInitThunk
15 ntdll!RtlUserThreadStart
Quuxplusone commented 6 years ago

I reproed this with a debug build of lld and found that the crash occurs when merging symbol records from obj\base\third_party\dynamic_annotations\dynamic_annotations.lib//dynamic_anotations.obj

This object file references a type server PDB, and for some reason this type server PDB hasn't yet had its types merged in.

Therefore, we try to remap a symbol record using the referenced type index, but the type can't be found.

I didn't dig deep enough to figure out why this doesn't happen with other type server records since supporting /Zi object files is lower priority than other things, but this should at least be a clue / reminder for whenever we get around to taking a more serious look at this.