[lld] r322264 - Fix thread race between SectionPiece's OutputOff and Live members

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 01:53:13 PST 2018


Should this be merged into 6.0?

From: llvm-commits <llvm-commits-bounces at lists.llvm.org> on behalf of Dimitry Andric via llvm-commits <llvm-commits at lists.llvm.org>
Reply-To: Dimitry Andric <dimitry at andric.com>
Date: Thursday, January 11, 2018 at 12:04 AM
To: "llvm-commits at lists.llvm.org" <llvm-commits at lists.llvm.org>
Subject: [lld] r322264 - Fix thread race between SectionPiece's OutputOff and Live members

Author: dim
Date: Thu Jan 11 00:03:22 2018
New Revision: 322264

URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D322264-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Xzeycr3aeaH2s-dbwn36tREoztaX3UBAqTs_Puspq3c&s=l5swfwKkexIb_mVxncjt1ygki08cGq_Xj6D46fD5OqM&e=
Log:
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://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D41884&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Xzeycr3aeaH2s-dbwn36tREoztaX3UBAqTs_Puspq3c&s=dy5VuBxeCmtDUygIahWUYtVcPQTAypaA-1W-lJsyTMc&e=

Modified:
    lld/trunk/ELF/SyntheticSections.cpp

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_lld_trunk_ELF_SyntheticSections.cpp-3Frev-3D322264-26r1-3D322263-26r2-3D322264-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Xzeycr3aeaH2s-dbwn36tREoztaX3UBAqTs_Puspq3c&s=Y5724oLNQOEvmUSt4gRXiCeTBv9BgWDLqZc-WjB_LyQ&e=
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Jan 11 00:03:22 2018
@@ -2451,10 +2451,8 @@ void MergeNoTailSection::finalizeContent
   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));
       }
     }


_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=Xzeycr3aeaH2s-dbwn36tREoztaX3UBAqTs_Puspq3c&s=YZq7G3sWEhLNixHYrxl6zXBuu0ZSTRGlLhLss21Ce2E&e=

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180111/47aea2be/attachment.html>


More information about the llvm-commits mailing list