summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch')
-rw-r--r--meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch b/meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch
new file mode 100644
index 0000000000..f46415f440
--- /dev/null
+++ b/meta/recipes-devtools/binutils/binutils/0001-gold-ensure-file_counts_lock-is-initialized-before-u.patch
@@ -0,0 +1,41 @@
1From de24fc96bf24fca470a9ca13176ad9ad9cc4d5a9 Mon Sep 17 00:00:00 2001
2From: Nick Gasson <nick.gasson@arm.com>
3Date: Mon, 2 Nov 2020 12:02:05 +0800
4Subject: [PATCH] gold: ensure file_counts_lock is initialized before using
5
6Since upgrading to binutils 2.35 I've been experiencing random memory
7corruption related crashes with ld.gold --threads. It's caused by
8multiple threads concurrently pushing elements onto the shared
9std::vector in File_read::record_file_read(). This vector is supposed to
10be protected by file_counts_lock, but that is initialized lazily and
11might be NULL when File_read::open() is called, in which case
12Hold_optional_lock silently skips locking it.
13
14Fix by calling the initialize() method before attempting to acquire the
15lock, the same as other places that use file_counts_lock.
16
17 PR 26827
18 * fileread.cc (File_read::open): Ensure file_counts_lock is
19 initialized.
20 * testsuite/Makefile.am (check_PROGRAMS): Add a test that passes
21 -Wl,--threads.
22 * testsuite/Makefile.in: Regenerate.
23
24Upstream-Status: Backport [af61e84fd2d from 2.36.0]
25Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
26---
27 gold/fileread.cc | 1 +
28 1 file changed, 1 insertion(+)
29
30diff --git a/gold/fileread.cc b/gold/fileread.cc
31index f5ca719360d..0b5228e2afd 100644
32--- a/gold/fileread.cc
33+++ b/gold/fileread.cc
34@@ -212,6 +212,7 @@ File_read::open(const Task* task, const std::string& name)
35 gold_debug(DEBUG_FILES, "Attempt to open %s succeeded",
36 this->name_.c_str());
37 this->token_.add_writer(task);
38+ file_counts_initialize_lock.initialize();
39 Hold_optional_lock hl(file_counts_lock);
40 record_file_read(this->name_);
41 }