summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2018-01-11 08:03:22 +0000
committerDimitry Andric <dimitry@andric.com>2018-01-11 08:03:22 +0000
commit656714a3110be7ae2a0bc8db193c0bf5b3d1ec2f (patch)
tree826ebe09253f9ae93f44fef11623ac820be04449
parent45fcbf0991057d22c82d9414ec565a70a3620584 (diff)
downloadbcm5719-llvm-656714a3110be7ae2a0bc8db193c0bf5b3d1ec2f.tar.gz
bcm5719-llvm-656714a3110be7ae2a0bc8db193c0bf5b3d1ec2f.zip
Fix thread race between SectionPiece's OutputOff and Live members
Summary: As reported in bug 35788, rL316280 reintroduces a race between two members of SectionPiece, which share the same 64 bit memory location. To fix the race, check the hash before checking the Live member, as suggested by Rafael. Reviewers: ruiu, rafael Reviewed By: ruiu Subscribers: smeenai, emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D41884 llvm-svn: 322264
-rw-r--r--lld/ELF/SyntheticSections.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 36e3ffa284e..d274a1905c3 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2451,10 +2451,8 @@ void MergeNoTailSection::finalizeContents() {
parallelForEachN(0, Concurrency, [&](size_t ThreadId) {
for (MergeInputSection *Sec : Sections) {
for (size_t I = 0, E = Sec->Pieces.size(); I != E; ++I) {
- if (!Sec->Pieces[I].Live)
- continue;
size_t ShardId = getShardId(Sec->Pieces[I].Hash);
- if ((ShardId & (Concurrency - 1)) == ThreadId)
+ if ((ShardId & (Concurrency - 1)) == ThreadId && Sec->Pieces[I].Live)
Sec->Pieces[I].OutputOff = Shards[ShardId].add(Sec->getData(I));
}
}
OpenPOWER on IntegriCloud