[lld] r358547 - Fix a crash bug caused by a nested call of parallelForEach.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 19:12:47 PDT 2019
Author: ruiu
Date: Tue Apr 16 19:12:47 2019
New Revision: 358547
URL: http://llvm.org/viewvc/llvm-project?rev=358547&view=rev
Log:
Fix a crash bug caused by a nested call of parallelForEach.
parallelForEach is not reentrant. We use parallelForEach to call
each section's writeTo(), so calling the same function within writeTo()
is not safe.
Fixes https://bugs.llvm.org/show_bug.cgi?id=41508
Differential Revision: https://reviews.llvm.org/D60757
Modified:
lld/trunk/wasm/OutputSections.cpp
Modified: lld/trunk/wasm/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/OutputSections.cpp?rev=358547&r1=358546&r2=358547&view=diff
==============================================================================
--- lld/trunk/wasm/OutputSections.cpp (original)
+++ lld/trunk/wasm/OutputSections.cpp Tue Apr 16 19:12:47 2019
@@ -110,8 +110,8 @@ void CodeSection::writeTo(uint8_t *Buf)
memcpy(Buf, CodeSectionHeader.data(), CodeSectionHeader.size());
// Write code section bodies
- parallelForEach(Functions,
- [&](const InputChunk *Chunk) { Chunk->writeTo(Buf); });
+ for (const InputChunk *Chunk : Functions)
+ Chunk->writeTo(Buf);
}
uint32_t CodeSection::numRelocations() const {
@@ -175,7 +175,7 @@ void DataSection::writeTo(uint8_t *Buf)
// Write data section headers
memcpy(Buf, DataSectionHeader.data(), DataSectionHeader.size());
- parallelForEach(Segments, [&](const OutputSegment *Segment) {
+ for (const OutputSegment *Segment : Segments) {
// Write data segment header
uint8_t *SegStart = Buf + Segment->SectionOffset;
memcpy(SegStart, Segment->Header.data(), Segment->Header.size());
@@ -183,7 +183,7 @@ void DataSection::writeTo(uint8_t *Buf)
// Write segment data payload
for (const InputChunk *Chunk : Segment->InputSegments)
Chunk->writeTo(Buf);
- });
+ }
}
uint32_t DataSection::numRelocations() const {
@@ -231,8 +231,8 @@ void CustomSection::writeTo(uint8_t *Buf
Buf += NameData.size();
// Write custom sections payload
- parallelForEach(InputSections,
- [&](const InputSection *Section) { Section->writeTo(Buf); });
+ for (const InputSection *Section : InputSections)
+ Section->writeTo(Buf);
}
uint32_t CustomSection::numRelocations() const {
More information about the llvm-commits
mailing list