From: robert Date: Mon, 4 Dec 2023 14:24:29 +0000 (+0000) Subject: protect access to the gnu warning map with a mutex to avoid random crashes X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e8ae9400fee88c6e6c55dbe389a1b300f24fd7f8;p=openbsd protect access to the gnu warning map with a mutex to avoid random crashes discussed with, tested by and ok tb@ --- diff --git a/gnu/llvm/lld/ELF/InputFiles.cpp b/gnu/llvm/lld/ELF/InputFiles.cpp index 05fc61997fb..e7c94b852f1 100644 --- a/gnu/llvm/lld/ELF/InputFiles.cpp +++ b/gnu/llvm/lld/ELF/InputFiles.cpp @@ -67,7 +67,9 @@ std::string lld::toString(const InputFile *f) { // .gnu.warning.SYMBOL are treated as warning symbols for the given symbol void lld::parseGNUWarning(StringRef name, ArrayRef data, size_t size) { + static std::mutex mu; if (!name.empty() && name.startswith(".gnu.warning.")) { + std::lock_guard lock(mu); StringRef wsym = name.substr(13); StringRef s(data.begin()); StringRef wng(s.substr(0, size)); diff --git a/gnu/llvm/lld/ELF/Relocations.cpp b/gnu/llvm/lld/ELF/Relocations.cpp index 3c9e7e450c1..9bdbad2d48a 100644 --- a/gnu/llvm/lld/ELF/Relocations.cpp +++ b/gnu/llvm/lld/ELF/Relocations.cpp @@ -792,6 +792,7 @@ void elf::reportUndefinedSymbols() { static void reportGNUWarning(Symbol &sym, InputSectionBase &sec, uint64_t offset) { + std::lock_guard lock(relocMutex); if (sym.gwarn) { StringRef gnuWarning = gnuWarnings.lookup(sym.getName()); // report first occurance only