[PATCH] Fix race condition in Defined Atom ordinal computation.
Jean-Daniel Dupas
mailing at xenonium.com
Fri Mar 13 16:01:04 PDT 2015
Hi ruiu,
Defined atom are allocated in multiples thread. The static counter must be atomic, else the ordinal is not guarantee to be unique (which is required by the Mach-O writer).
REPOSITORY
rL LLVM
http://reviews.llvm.org/D8336
Files:
include/lld/Core/Simple.h
Index: include/lld/Core/Simple.h
===================================================================
--- include/lld/Core/Simple.h
+++ include/lld/Core/Simple.h
@@ -174,7 +174,7 @@
class SimpleDefinedAtom : public DefinedAtom {
public:
explicit SimpleDefinedAtom(const File &f) : _file(f) {
- static uint32_t lastOrdinal = 0;
+ static std::atomic<uint32_t> lastOrdinal;
_ordinal = lastOrdinal++;
_references.setAllocator(&f.allocator());
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8336.21969.patch
Type: text/x-patch
Size: 464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150313/b58a8454/attachment.bin>
More information about the llvm-commits
mailing list