Skip to content

Commit 0eebd31

Browse files
committed
Merging r358547:
------------------------------------------------------------------------ r358547 | ruiu | 2019-04-16 19:12:47 -0700 (Tue, 16 Apr 2019) | 9 lines 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 ------------------------------------------------------------------------ llvm-svn: 360791
1 parent d9ccd0d commit 0eebd31

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lld/wasm/OutputSections.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ void CodeSection::writeTo(uint8_t *Buf) {
111111
memcpy(Buf, CodeSectionHeader.data(), CodeSectionHeader.size());
112112

113113
// Write code section bodies
114-
parallelForEach(Functions,
115-
[&](const InputChunk *Chunk) { Chunk->writeTo(Buf); });
114+
for (const InputChunk *Chunk : Functions)
115+
Chunk->writeTo(Buf);
116116
}
117117

118118
uint32_t CodeSection::numRelocations() const {
@@ -176,15 +176,15 @@ void DataSection::writeTo(uint8_t *Buf) {
176176
// Write data section headers
177177
memcpy(Buf, DataSectionHeader.data(), DataSectionHeader.size());
178178

179-
parallelForEach(Segments, [&](const OutputSegment *Segment) {
179+
for (const OutputSegment *Segment : Segments) {
180180
// Write data segment header
181181
uint8_t *SegStart = Buf + Segment->SectionOffset;
182182
memcpy(SegStart, Segment->Header.data(), Segment->Header.size());
183183

184184
// Write segment data payload
185185
for (const InputChunk *Chunk : Segment->InputSegments)
186186
Chunk->writeTo(Buf);
187-
});
187+
}
188188
}
189189

190190
uint32_t DataSection::numRelocations() const {
@@ -232,8 +232,8 @@ void CustomSection::writeTo(uint8_t *Buf) {
232232
Buf += NameData.size();
233233

234234
// Write custom sections payload
235-
parallelForEach(InputSections,
236-
[&](const InputSection *Section) { Section->writeTo(Buf); });
235+
for (const InputSection *Section : InputSections)
236+
Section->writeTo(Buf);
237237
}
238238

239239
uint32_t CustomSection::numRelocations() const {

0 commit comments

Comments
 (0)