[PATCH] D140333: [lld][COFF] Fix lld-link crash when several .obj files built with /Zi refer to a .pdb file that failed to load

Sylvain Audi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 11:56:52 PST 2022


saudi created this revision.
saudi added reviewers: thakis, thieta, rnk.
saudi added a project: lld.
Herald added a project: All.
saudi requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch relaxes the constraints on the error message saved in `PDBInputFile` when failing to load a pdb file.

Storing an `Error` member infers that it must be accessed exactly once, which doesn't fit in several scenarios:

- If an invalid PDB file is provided as input file but never used, a loading error is created but never handled, causing an assert at shutdown
- PDB file created using `MSVC`'s `/Zi` option : The loading error message must be displayed once per obj file.

Also, the state of `PDBInputFile` was altered when reading (taking) the `Error` member, causing issues:

- making it look valid whereas it's not properly initialized
- read vs write concurrency on a same `PDBInputFile` in the `ghash` parallel algorithm

The solution adopted here was to instead store an optional error string, and generate Error objects from it on demand.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140333

Files:
  lld/COFF/DebugTypes.cpp
  lld/COFF/InputFiles.cpp
  lld/COFF/InputFiles.h
  lld/test/COFF/Inputs/pdb-type-server-corrupted-a.yaml
  lld/test/COFF/Inputs/pdb-type-server-corrupted-b.yaml
  lld/test/COFF/invalid-input-pdb.ll
  lld/test/COFF/pdb-type-server-corrupted.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140333.484028.patch
Type: text/x-patch
Size: 20587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221219/2adada02/attachment.bin>


More information about the llvm-commits mailing list