[LinkerWrapper] Fix memory issues due to unguarded accesses to global state
authorJoseph Huber <jhuber6@vols.utk.edu>
Tue, 31 Jan 2023 15:50:40 +0000 (09:50 -0600)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 1 Feb 2023 14:12:10 +0000 (08:12 -0600)
commit9c4591d7f3acaa00318900bdba4b4ba26c99c666
tree9987d29f88eb239dfb079f5caa81b490b3bfb2de
parentc05ace1067bd21abf504d75f1efb5cf0e1c3fb51
[LinkerWrapper] Fix memory issues due to unguarded accesses to global state

There were intemittent errors in the linker wrapper when using the
sanitizers in parallel. First, this is because the `TempFiles` global
was not guarded when creating a new file. Second, even though the `Args`
list is passed as const, the internal state is mutable when adding a
string. So that needs to be guarded too.

Fixes https://github.com/llvm/llvm-project/issues/60437

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D142985
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp